|
 |
|
รบกวนให้ช่วยหน่อยครับ Code php ผมอัพรูปไม่ขึ้นอะครับ รบกวนหน่อยครับ จะสอบวันศุกร์นีแล้วครับยังไม่ได้เลย |
|
 |
|
|
 |
 |
|
นี้ครับโ Code
<?
include "../include/ConnectionDb.php";
if ($_REQUEST['do']=="add"){
}elseif ($_REQUEST['do']=="delete"){
} elseif ($_REQUEST['do']=="frmedit"){
}elseif ($_REQUEST['do']=="edit"){
}
if($_REQUEST['do']=="add"){
$itemno=$_POST['itemid'];
$typeid=$_POST['ref_typeid'];
$catid=$_POST['ref_catid'];
$tname=$_POST['itemName'];
$detail=$_POST['detail'];
$photo=$_POST['picture'];
$price=number_format($_POST['unitprice'],2,'.','');
if(($itemid=="") or ($tname=="") or ($typeid="") or ($catid=="")){
echo "คุณใส่ข้อมูลไม่ครบ";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
$photo=$_FILES['photo'] ['tmp_name'];
$photo_name=$_FILES['photo'] ['name'];
$photo_size=$_FILES['photo'] ['size'];
$photo_type=$_FILES ['photo'] ['type'];
if($photo==""){
$sql="SELECT * FORM tbProduct oder by itemid ";
$sql_add="INSERT INTO tbProduct (itemid, itemName, unitprice, ref_catid, ref_typeid, detail, picture) VALUES ('$itemno','$tname' ,'$price' ,'$ref_catid' ,'$ref_typeid', '$detail', '');";
$result_add=mysql_query($sql_add);
echo "บันทึกข้อมูลเรียบร้อยแล้ว";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
$array_last=explode(".",$photo);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg"){
$set_photo=explode(".". $photo_name);
$pname="item_" .$_POST['itemid'];
$plname=$set_photo [1];
$photoname=$pname ."." .$plname;
copy($photo, "../images/item/" .".$photoname");
$sql="SELECT * FORM tbProduct oder by itemid ";
$sql_add="INSERT INTO tbProduct (itemid, itemName, unitprice, ref_catid, ref_typeid, detail, picture) VALUES ('$itemid', '$tname', '$price', '$ref_catid', '$ref_ typeid', '$detail', '$photo');";
$result_add=mysql_query ($sql_add);
echo "บันทึกข้อมูลเรียบร้อยแล้ว";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
echo "<h3>ERROR : ไม่สามารถบันทึกไฟล์รูปภาพได้ต้องเป็น .jpg, .gif เท่านั้น)</h3>";
echo "<meta http-equiv='refresh' content='10;url=addProduct.php'>";
}
unlink ($photo);
}
}
}
Tag : PHP

|
ประวัติการแก้ไข 2012-02-22 15:39:18 2012-02-22 15:47:20
|
 |
 |
 |
 |
Date :
2012-02-22 15:33:28 |
By :
marine446 |
View :
1297 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
copy($photo, "../images/item/" .".$photoname");
แก้เป็น
copy($photo, "../images/item/" .$photoname);
|
 |
 |
 |
 |
Date :
2012-02-22 15:48:29 |
By :
randOmizE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค้ดเยอะแบบนี้ เอาใส่ tag PHP ไว้ก็ดีน่ะครับ
อ่ะ เอาใส่ให้  
Code (PHP)
include "../include/ConnectionDb.php";
if ($_REQUEST['do']=="add"){
}elseif ($_REQUEST['do']=="delete"){
} elseif ($_REQUEST['do']=="frmedit"){
}elseif ($_REQUEST['do']=="edit"){
}
if($_REQUEST['do']=="add"){
$itemno=$_POST['itemid'];
$typeid=$_POST['ref_typeid'];
$catid=$_POST['ref_catid'];
$tname=$_POST['itemName'];
$detail=$_POST['detail'];
$photo=$_POST['picture'];
$price=number_format($_POST['unitprice'],2,'.','');
if(($itemid=="") or ($tname=="") or ($typeid="") or ($catid=="")){
echo "คุณใส่ข้อมูลไม่ครบ";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
$photo=$_FILES['photo'] ['tmp_name'];
$photo_name=$_FILES['photo'] ['name'];
$photo_size=$_FILES['photo'] ['size'];
$photo_type=$_FILES ['photo'] ['type'];
if($photo==""){
$sql="SELECT * FORM tbProduct oder by itemid ";
$sql_add="INSERT INTO tbProduct (itemid, itemName, unitprice, ref_catid, ref_typeid, detail, picture) VALUES ('$itemno','$tname' ,'$price' ,'$ref_catid' ,'$ref_typeid', '$detail', '');";
$result_add=mysql_query($sql_add);
echo "บันทึกข้อมูลเรียบร้อยแล้ว";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
$array_last=explode(".",$photo);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg"){
$set_photo=explode(".". $photo_name);
$pname="item_" .$_POST['itemid'];
$plname=$set_photo [1];
$photoname=$pname ."." .$plname;
copy($photo, "../images/item/" .".$photoname");
$sql="SELECT * FORM tbProduct oder by itemid ";
$sql_add="INSERT INTO tbProduct (itemid, itemName, unitprice, ref_catid, ref_typeid, detail, picture) VALUES ('$itemid', '$tname', '$price', '$ref_catid', '$ref_ typeid', '$detail', '$photo');";
$result_add=mysql_query ($sql_add);
echo "บันทึกข้อมูลเรียบร้อยแล้ว";
echo "<meta http-equiv='refresh' content='1;url=addProduct.php'>";
}else{
echo "<h3>ERROR : ไม่สามารถบันทึกไฟล์รูปภาพได้ต้องเป็น .jpg, .gif เท่านั้น)</h3>";
echo "<meta http-equiv='refresh' content='10;url=addProduct.php'>";
}
unlink ($photo);
}
}
}
|
ประวัติการแก้ไข 2012-02-22 15:51:54
 |
 |
 |
 |
Date :
2012-02-22 15:50:21 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ยังไม่ได้อยู่ดีอะครับ งงมากเลย
|
ประวัติการแก้ไข 2012-02-22 15:53:05
 |
 |
 |
 |
Date :
2012-02-22 15:51:44 |
By :
marine446 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|