Hi
I need to create an update form that firstly selects the data and displays in a form then when the date is edited the database will chenge to the new data. I know how to create the select query and an update query but whn put together they just do not work. The $id variable is pulled from the previous page.
Here is the code:
<?php
$id = isset($GET['id'])? $GET['id']:NULL;
include "db_conn_open.php";
$query = "SELECT * FROM products WHERE pID='$id'";
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$pid=mysql_result($result,$i,"pID");
$pname=mysql_result($result,$i,"pName");
$pprice=mysql_result($result,$i,"pPrice");
?>
<html>
<title>Test</title>
<body>
<form action="post">
<table width="541" border="0">
<tr>
<td colspan="2"><strong>QUOTATION PRICE UPDATE</strong></td>
</tr>
<tr>
<td width="119">Product ID: </td>
<td width="412"><input type="text" name="pID" value="<? echo "$pid"; ?>"></td>
</tr>
<tr>
<td>Product Name: </td>
<td><input type="text" name="pName" value="<? echo "$pname"; ?>"></td>
</tr>
<tr>
<td>Product Price:</td>
<td><input type="text" name="pPrice" value="<? echo "$pprice"; ?>"></td>
</tr>
<tr>
<td> </td>
<td><input type="Submit" value="Update" />