1 / 12

บทที่ 9

บทที่ 9. การเขียน PHP ติดต่อ MySQL. การแก้ไขข้อมูล. สร้าง formupdate.php. สร้าง formupdate.php. นำฟอร์มเดิมของการเพิ่มข้อมูลมาแก้ไข เพิ่ม สคริปต์ php ส่วนแรก เพิ่มหลังจากแท็กเปิด <body>. <?php include " config . php " ;

nysa
Télécharger la présentation

บทที่ 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. บทที่ 9 การเขียน PHP ติดต่อ MySQL

  2. การแก้ไขข้อมูล • สร้าง formupdate.php

  3. สร้าง formupdate.php • นำฟอร์มเดิมของการเพิ่มข้อมูลมาแก้ไข • เพิ่ม สคริปต์ php ส่วนแรก เพิ่มหลังจากแท็กเปิด <body> <?php include "config.php"; $sql = "SELECT * FROM register where mem_id='$mem_id'"; $result = mysql_query( $sql, $conn ); $am = mysql_fetch_array($result); ?>

  4. สร้าง formupdate.php (ต่อ) • นำข้อมูลจาก database ขึ้นมาแสดงตรงตำแหน่งที่ต้องการ • นำเมาส์คลิกตรง inputobject ชื่อสกุล <input name="name" type="text" id="name3" value="<?=$am[mem_name];?>" size="50" maxlength="50">

  5. สร้าง formupdate.php (ต่อ) • นำเมาส์คลิกตรง inputobject ที่อยู่ <textarea name="address" cols="30" rows="4" id="textarea2"><?=$am[mem_add];?></textarea>

  6. สร้าง formupdate.php (ต่อ) • ตรงตำแหน่ง เพศ แทรกสคริปต์ php <label> <? if($am[gender] == "male"){$sexm="checked";}else{$sexm="";} if($am[gender] == "female"){$sexf="checked";}else{$sexf="";} ?> <input type="radio" name="gender" value="male" <?=$sexm;?>>ชาย</label> <label> <input type="radio" name="gender" value="female" <?=$sexf;?>>หญิง</label>

  7. สร้าง formupdate.php (ต่อ) • คลิกตรง select เลือกอายุ <select size="1" name="age"> <? if($am[age] == "18-22"){$age="selected";}else{$age="";} ?> <option value="18-22" <?=$age;?>>18-22</option> <? if($am[age] == "23-27"){$age="selected";}else{$age="";} ?> <option value="23-27"<?=$age;?>>23-27</option>

  8. <? if($am[age] == "28-32"){$age="selected";}else{$age="";} ?> <option value="28-32"<?=$age;?>>28-32</option> <? if($am[age] == "33-40"){$age="selected";}else{$age="";} ?> <option value="33-40" <?=$age;?>>33-40</option> </select>

  9. สร้าง formupdate.php (ต่อ) • คลิกเลือกชื่อล็อกอิน <input name="login" type="text" id="login3" value="<?=$am[login];?>" size="20" maxlength="15">

  10. สร้าง formupdate.php (ต่อ) • คลิกเลือกรหัสผ่าน <input name="login" type="text" id="login3" value="<?=$am[pass];?>" size="20" maxlength="15">

  11. สร้าง formupdate.php (ต่อ) • คลิกเลือกแถวกิจกรรมยามว่าง

  12. <? if($am[acti1] == "read"){$a1="checked";}else{$a1="";} if($am[acti2] == "sport"){$a2="checked";}else{$a2="";} if($am[acti3] == "movie"){$a3="checked";}else{$a3="";} ?> <input name="acti1" type="checkbox" id="acti13" value="read" <?=$a1;?>>อ่านหนังสือ<br> <input name="acti2" type="checkbox" id="acti23" value="sport" <?=$a2;?>>เล่นกีฬา<br> <input name="acti3" type="checkbox" id="acti33" value="movie" <?=$a3;?>>ดูหนัง<br>

More Related