<?
$fileupload=$_FILES['fileupload']['tmp_name'];
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];
include"connect.php";
$sql="INSERT INTO tbl_image values(null,'')";
$result=mysql_db_query($dbname,$sql);
if($fileupload)
{
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg")
{
$sql2="select max(id_prd) from tbl_image";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$row[0].".".$lastname;
copy($fileupload,"photo/".$photoname);
$sql3="update tbl_image set photo_prd='$photoname'where id_prd='$row[0]'";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
echo"<h3>เพิ่มภาพ QR Code เรียบร้อยแล้ว</h3>";
echo"[<a href=admin_product_add.php>กลับ</a>]";
mysql_close();
?>
เพิ่มข้อมูลลง sql ไม่ได้ครับ ในส่วนของ phopo_prd ไม่มีการเพิ่มข้อมูลลงไป
$fileupload=$_FILES['fileupload']['tmp_name'];
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];
include"connect.php";
$sql="INSERT INTO tbl_image values(null,'')";
$result=mysql_db_query($dbname,$sql);
if($fileupload)
{
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg")
{
$sql2="select max(id_prd) from tbl_image";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$row[0].".".$lastname;
copy($fileupload,"photo/".$photoname);
$sql3="update tbl_image set photo_prd='$photoname'where id_prd='$row[0]'";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
echo"<h3>เพิ่มภาพ QR Code เรียบร้อยแล้ว</h3>";
echo"[<a href=admin_product_add.php>กลับ</a>]";
mysql_close();
?>