I have 2 table
locations
- location_id
- location_code
- box_number
boxes
- box_id
- box_number
- location_code
Somehow I managed to set all location_code in boxes to 0.
How do I select all locations, select all boxes, then Update boxes set locations_code = location_code where box_number is the same.
I need to get those values back into my db urgently.
Here is what I've tried, but it's obviously not right.
And I still havn't done the Update query.
Any help guys?
<?
$boxselect = mysql_query("Select * from boxes",$con);
$boxs = mysql_num_rows($boxselect);
while($box = mysql_fetch_array($boxselect, MYSQL_ASSOC))
{
$location = mysql_query("Select * from location where box_number = ".$box['location_code']."",$con);
$locationr = mysql_num_rows($location);
while($loc = mysql_fetch_array($location, MYSQL_ASSOC))
{
if ($loc)
{
?>
<form action="" method="post" ">
<table width="62%" border="0">
<tr>
<td width="45%"><div align="right">Location Code from Location Table:</div></td>
<td width="55%"> <div align="left">
<input name="location_code" type="text" value="<?php echo $loc['location_code'];?>" size="40" />
</div>
</td>
</tr>
<tr>
<td height="24"><div align="right">Box Number:</div></td>
<td><div align="left"> <input type="text" name="box_number" value="<?php echo $box['box_number'];?>" size="40"></div></td>
</tr>
</table>
<input type="Submit" name="Edit" value="Edit">
</form>
<?
}
}
}
?>
Thanks