Skip to content

Instantly share code, notes, and snippets.

@candycub
Last active February 6, 2016 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save candycub/1326835ba9b464cda6ec to your computer and use it in GitHub Desktop.
Save candycub/1326835ba9b464cda6ec to your computer and use it in GitHub Desktop.
สร้างไฟล์ edit.php เพื่อเป็น Form สำหรับแก้ไขข้อมูลสินค้า และส่งข้อมูลไปที่ไฟล์ save_edit.php เพื่ิอบันทึกการแก้ไข
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>กรอกข้อมูลสินค้า</title>
</head>
<body>
<p align="center">
<a href="form.html">กรอกข้อมูล</a>|
|<a href="show.php">แสดงรายการสินค้า</a>
</p>
<?php
include"c.php";
$product_id = $_GET['product_id'];
$sql = mysqli_query($c,"SELECT * FROM tb_product WHERE product_id = '".$product_id."' ");
$row = mysqli_fetch_assoc($sql);
?>
<table border="1" align="center">
<form action="save_edit.php?product_id=<?=$row['product_id']; ?>" method="post">
<tr>
<td>กรอกชื่อสินค้า : </td>
<td>
<input type="text" name="product_name"
value="<?=$row['product_name']; ?>">
</td>
</tr>
<tr>
<td>กรอกราคาสินค้า : </td>
<td>
<input type="text" name="product_price"
value="<?=$row['product_price']; ?>">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="บันทึก">
</td>
</tr>
</form>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment