พี่ช่วยดูโค้ดให้หน่อยครับ คือต้องการให้บันทึกลงฐานข้อมูลพร้อมชื่อภาพ และต้องการให้เช็คค่าว่างด้วยครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา พี่ช่วยดูโค้ดให้หน่อยครับ คือต้องการให้บันทึกลงฐานข้อมูลพร้อมชื่อภาพ และต้องการให้เช็คค่าว่างด้วยครับ
พี่ช่วยดูโค้ดให้หน่อยครับ คือต้องการให้บันทึกลงฐานข้อมูลพร้อมชื่อภาพ และต้องการให้เช็คค่าว่างด้วยครับ
Copy
frm_product <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- #apDiv1 { position:absolute; left:392px; top:12px; width:521px; height:362px; z-index:1; } --> </style> </head> <body> <div id="apDiv1"> <form action="php_multiple_upload2.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <div align="center"> <babel> <p align="center">กรุณากรอกข้อมูลรายละเอียดของรถ </label> </p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33%">ยี่ห้อรถมอเตอร์ไซค์ :</td> <td width="67%"><input type="text" name="brand_pro" id="brand_pro" /></td> </tr> <tr> <td>รุ่นของรถ : </td> <td><input type="text" name="generate_pro" id="generate_pro" /></td> </tr> <tr> <td>ปีที่จดทะเบียน :</td> <td><input type="text" name="registyear_pro" id="registyear_pro" /></td> </tr> <tr> <td>สีรถ :</td> <td><input type="text" name="color_pro" id="color_pro" /></td> </tr> <tr> <td>ราคาที่ต้องการขาย :</td> <td><input type="text" name="price_pro" id="price_pro" /></td> </tr> <tr> <td><div align="center">ภาพถ่ายรถ :</div></td> <td> </td> </tr> <tr> <td><div align="center">รูปของเล่มทะเบียน</div></td> <td><label> <input type="file" name="fileUpload1" /> </label></td> </tr> <tr> <td><div align="center">รูปที่1:</div></td> <td><label> <input type="file" name="fileUpload2" /> </label></td> </tr> <tr> <td><div align="center">รูปที่2:</div></td> <td><label> <input type="file" name="fileUpload3" /> </label></td> </tr> <tr> <td><div align="center">รูปที่3:</div></td> <td><label> <input type="file" name="fileUpload4" /> </label></td> </tr> <tr> <td><div align="center">รูปที่4:</div></td> <td><label> <input type="file" name="fileUpload5" /> </label></td> </tr> <tr> <td><div align="center">รูปที่5:</div></td> <td><label> <input type="file" name="fileUpload6" /> </label></td> </tr> <tr> <td> </td> </tr> </table> <td><div align="center"> <label> </br> <input name="hdnLine" type="hidden" value="6"> <input type="submit" name="button" id="button" value="บันทึกการฝากขาย" /> </label> </div></td> </form> </div> </body> </html> ฟอร์มadd_product.php <?php include"../connect.php"; if ($_POST["button"] == "บันทึกการฝากขาย"){ if($_POST["brand_pro"]=="" or $_POST["generate_pro"]=="" or $_POST["registyear_pro"]=="" or $_POST["color_pro"]=="" or $_POST["price_pro"]==""){ echo "กรุณากรอกข้อมูลให้ครบด้วย"; }else{ $sql="insert into product (brand_pro,generate_pro,registyear_pro,color_pro,price_pro) values ('$_POST[brand_pro]','$_POST[generate_pro]','$_POST[registyear_pro]','$_POST[color_pro]','$_POST[price_pro]')"; $objQuery= mysql_query($sql); if ($objQury){ echo"ok"; }else{ echo"error"; } } } for($i=1;$i<=(int)($_POST["hdnLine"]);$i++) { if($_FILES["fileUpload".$i]["name"] != "") { if(move_uploaded_file($_FILES["fileUpload".$i]["tmp_name"],"uploaded/".$_FILES["fileUpload".$i]["name"])) { $fileName[] = $_FILES["fileUpload".$i]["name"]; } } } #บันทึกชื่อไฟล์ลงฐานข้อมูล $strSQL = "INSERT INTO product "; $strSQL .="(imageregist_pro,image1_pro,image2_pro,image3_pro,image4_pro,image5_pro) VALUES ('".$fileName[0]."','".$fileName[1]."','".$fileName[2]."','".$fileName[3]."','".$fileName[4]."','".$fileName[5]."')"; if(mysql_query($strSQL)) { echo "อัพโหลดไฟล์เรียบร้อยเเล้ว<br>"; } echo "<br><a href='php_multiple_upload3.php'>ดูไฟล์ภาพ</a>"; mysql_close(); ?>

คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ