 |
|
คือมันสามารถแก้ไขและแสดงข้อมูลในฐานข้อมูลได้ครับ แต่พอส่งข้อมูลเพื่อที่จะบันทึกลงฐานข้อมูลมันไม่สามารถบันทึกได้ครับ ผมไม่แน่ใจว่าเป็นที่ List Box หรือเปล่า รบกวนช่วยดูให้ทีนะครับ ขอบคุณครับ
album edite.php
<? include 'head.php';?>
<?
include "connect.php";
include "function.php";
$sql="select * from album where id_album='$id_edit'";
$result=mysql_db_query($dbname,$sql);
$r=mysql_fetch_array($result);
$id_album=$r[id_album];
$type=$r[type];
$title_album=$r[title_album];
$artist_album=$r[artist_album];
$detail_album=$r[detail_album];
$picture_album=$r[picture_album];
?>
<body>
<!-- /head -->
<!-- Content -->
<div class="featureEvent col-sm-12">
<div id="newsBox" class="col-sm-12">
<h3 class="text-capitalize">แก้ไขอัลบั้มผลงานเพลง</h3>
<hr>
</div>
<div id="newsBox" class="col-sm-12 container">
<FORM ACTION="album_edit2.php" METHOD="POST" ENCTYPE="multipart/form-data">
<TABLE>
<TR>
<TD><B>ปีที่ออก: </B></TD>
<TD>
<SELECT NAME="type">
<OPTION VALUE="0">-- เลือกปี -- </OPTION>
<?
for ($i=1;$i<=count($yearalbum);$i++) {
if ($year_album==$i) {
echo "<OPTION VALUE='$i' SELECTED>
$yearalbum[$i]</OPTION>";
} else {
echo "<option value='$i'>$yearalbum[$i] </option>";
}
}
?>
</SELECT> *
</TD>
</TR>
<TR>
<TD><B>ชื่ออัลบั้ม : </B></TD>
<TD><INPUT NAME="title_album" TYPE="text" SIZE="50" value="<?=$title_album?>" *</TD>
</TR>
<TR>
<TD><B>ซื่อศิลปิน : </B></TD>
<TD>
<?
// ติดต่อฐานข้อมูล
$link=mysql_connect("localhost","root","root") or die("error".mysql_error());
mysql_select_db("loveis",$link);
?>
<select name="artist_album" >
<?php
$q="select * from artist ";
$qr=mysql_query($q);
while($rs=mysql_fetch_array($qr)){
?>
echo "<option value="<?=$rs['name_artist']?>"><?=$rs['name_artist']?><? $artist_album ?></option>";
<? } ?>
</select></TD>
</TR>
<TR>
<TD VALIGN="top"><B>รายละเอียดอัลบั้ม :</B></TD>
<TD><TEXTAREA NAME="detail_album" TYPE="text" COLS="55" ROWS="8"><?=$detail_album?></TEXTAREA>*</TD>
</TR>
<TR>
<TD VALIGN="top"><B>รูปอัลบั้ม:</B></TD>
<TD> <?
if ($picture_album) {
echo "<INPUT TYPE='checkbox' NAME='chkdel' VALUE='1'> ลบรูปภาพ ";
echo "<A HREF='photoalbum/$picture_album' TARGET='_blank'> แสดงรูปภาพ </A><BR>";
} else {
echo "<INPUT NAME='photo' TYPE='file' ><BR>";
}
?>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="hidden" NAME='id_edit' VALUE="<?=$id_edit?>">
<INPUT NAME="photo_del" TYPE="hidden" VALUE="<?=$picture_album?>">
</TD>
<TD><INPUT TYPE="Submit" VALUE="Submit">
<INPUT TYPE="Reset" VALUE="Reset"> </TD>
</TR>
</TABLE>
</FORM>
[ <A HREF="album.php">กลับหน้าหลัก</A> ]
<hr>
<div>
</div>
</div>
</body>
</html>
----------------------------------------------------------------
album edite.php
<?
$id_edit=$_POST['id_edit'];
$type=$_POST['type'];
$title_album=$_POST['title_album'];
$artist_album=$_POST['artist_album'];
$detail_album=$_POST['detail_album'];
$chkdel=$_POST['chkdel'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
include "connect.php";
if ($chkdel=="1") {
$sql="update album set picture_album='' where id_album='$id_edit' ";
mysql_db_query($dbname,$sql);
unlink("photoalbum/$photo_del");
}
if ($photo) {
$ext = strtolower(end(explode('.', $photo_name)));
if ($ext == "jpg" or $ext == "jpeg" or $ext=="gif" or $ext=="png") {
$filename=$id_edit.".".$ext;
copy($photo,"photoalbum/$filename");
$sql="update album set picture_album='$filename' where id_album='$id_edit' ";
mysql_db_query($dbname,$sql);
}
}
$sql="update album set
type='$year_album',title_album='$title_album',artist_album='$artist_album',detail_album='$detail_album' where id_album='$id_edit' ";
$result=mysql_db_query($dbname,$sql);
if ($result) {
echo "<h3>แก้ไขเสร็จเรียบร้อย</h3>";
echo "[ <a href=album.php>Back</a> ] ";
} else {
echo "<h3>ไม่สามารถแก้ไขได้</h3>";
}
mysql_close();
?>
Tag : PHP, MySQL, HTML/CSS
|
|
 |
 |
 |
 |
Date :
2015-06-11 02:55:51 |
By :
bakerylove |
View :
687 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |