รบกวนช่วยแนะนำโค้ดทีค่ะ ถ้าไม่มีรูปใน DB ให้ insert ถ้ามีอยู่แล้วให้ update ตอนนี้มีแต่ updateค่ะ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา รบกวนช่วยแนะนำโค้ดทีค่ะ ถ้าไม่มีรูปใน DB ให้ insert ถ้ามีอยู่แล้วให้ update ตอนนี้มีแต่ updateค่ะ
รบกวนช่วยแนะนำโค้ดทีค่ะ ถ้าไม่มีรูปใน DB ให้ insert ถ้ามีอยู่แล้วให้ update ตอนนี้มีแต่ updateค่ะ
Copy
ตามตัวอย่างเลยค่ะ ตอนนี้ update ขอมูลแล้ว ต้องใส่เงื่อนไขยังไงคะให้มัน insert ได้
<? $crews =$_GET["id"]; if(!empty($crews)) { $sql="select*from crew_documents where cd_fk_nd_id='18' and cd_fk_cp_id = '".$crews."'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); } if(!empty($_FILES['cv_upload'])){ $file=$_FILES['cv_upload']; if($file['name']!=""){ $path="document/".$file['name']; if(file_exists("../".$path)){ unlink("../".$path); } move_uploaded_file($file['tmp_name'],$path); $sql="update crew_documents set cd_file='".$file['name']."' where cd_fk_nd_id='18' and cd_fk_cp_id = '".$crews."'"; mysql_query($sql); echo ("<script>window.location='crew_profile_edit.php?id=".$crews."'</script>"); } ?>นี่ส่วนดีไซต์ค่ะ
<div class="form-group col-xs-12 col-sm-6 col-md-6"> <label>SeamanBook :</label><br /> <img src="document/<?=$row2['cd_file']?>" width="150" height="150"/><br /><br /> <div class="col-sm-4 input-group"> <input type="text" class="form-control" value="<?=$row2["cd_file"] ?>" readonly> <span class="input-group-btn"> <span class="btn btn-primary btn-file"> Browse… <input type="file" name="seamanbook_upload" id="seamanbook_upload" multiple="true"> </span> </span> </div>
Thepaysz
183.88.103.xxx
28-09-2015
10:35:21
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ