i have the below code which is populating my drop down with the product names stored in tblproduct. the price of the products are stored in another table called tblretprod. the common field between the tables is the prod_id.
when i am selecting the product name, the price related to the product is not being displayed.
how can i update the price in tblretprod for each product as well when i change the price displayed to another one?
here is the code populating the select drop down.
<!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>Update product</title>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.prod_name.options[form.prod_name.options.selectedIndex].value;
//var description1=form.description.value;
self.location='upd_prod.php?prod_name=' + val;
//+'&description=' +description1;
}
</script>
<link href="CSS/update.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include('db_connect.php');
@$prod_name=$_GET['prod_name'];
$query=mysql_query("select p.prod_name, pr.prod_price from tblproduct p INNER JOIN tblretprod pr ON p.prod_id = pr.prod_id");
?>
<div id="stylized" class="myform">
<form id="form" name="upd_prod" method="post" action="updprod.php">
<h2 align="center"><b>- Update Product -</b></h2>
<table width="1000" border="0">
<tr>
<td><div align="right">Product Name</div></td>
<td>
<?PHP
echo "<select name='prod_name' onchange=\"reload(this.form)\"><option value=''>select one</option>";
while($row1 = mysql_fetch_array ($query)) {
if($row1['0']==@$prod_name){echo "<option selected value='".$row1['0']."'>".$row1['0']."</option>";}
else{echo "<option value=\"".$row1['0']."\">".$row1['0']."</option>";}
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td><div align="right">Product Price (MRU)</div></td>
<td><input type="text" name="prod_price" id="prod_price" value = "<?PHP print $row['prod_price'] ?>"/></td>
</tr>
</table>
<p align="center">
<input type="submit" class="button" name="update" id="update" value="<-- Update product -->" />
</p>
</form>
</div>
</body>
</html>
error message received is
Notice: Undefined variable: row in C:\wamp\www\buysmart_site\upd_prod.php on line 61