Hi
I have an "Edit Info" page which is not working quite right or at least not the way it seems like it should.
I make a query to bring up the info so the user can change it and then it goes to an update query.
It's working except there are two fields out of six which will not change. These two fields are also the ones the first query uses to find the results using the WHERE clause.
Neither of the two fields (store_name, store_no) are Unique or are Primary Keys. Is MySQL automatically locking them up or is there another possibility?
The code for the two pages follows. Thank you for any help.
Richard
...................................
First page...
<?
include ("connection stuff");
$sql = "select * from stores WHERE store_name = '$store_name' and store_no = '$store_no'";
echo $sql_result;
$sql_result = mysql_query($sql);
$msg = Mysql_num_rows($sql_result);
// start results formatting
echo "<p><table border='0' align='center'>";
echo "<tr bgcolor='#FFFFCC'>
<th>Zone</th>
<th>Store Name</th>
<th>Store #</th>
<th>Store Address</th>
<th>City</th>
<th>State</th>";
while ($row = mysql_fetch_array($sql_result)) {
$n1 = $row["zone"];
$n2 = $row["store_name"];
$n3 = $row["store_no"];
$n4 = $row["store_add"];
$n5 = $row["city"];
$n6 = $row["state"];
echo "<tr bgcolor='#99CCFF'>
<form method='post' action='edit_store2.php' method='post' onSubmit=\"return confirm('Edit store?');\">
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n1' name='zone' size='7'></td>
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n2' name='store_name' size='15'></td>
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n3' name='store_no' size='10'></td>
<td align='center'><textarea 'maxlength=200' name='store_add'>$n4</textarea></td>
<td align='center' valign='middle'><input type='text' 'maxlength=100' size='15' value='http://www.phpbuilder.com/board/archive/index.php/$n5' name='city'></td>
<td align='center' valign='middle'>
<SELECT NAME=state>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/$n6'>$n6</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/CA'>CA</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/ID'>ID</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/OR'>OR</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/WA'>WA</OPTION>
</SELECT></td></tr>
<tr>
<td align='center' valign='middle'><input type='submit' value='http://www.phpbuilder.com/board/archive/index.php/Edit Store'></td>
</tr>
</form>
</tr>";
}
echo"</table></p>";
mysql_free_result($sql_result);
MYSQL_CLOSE();
}
?>
.............................
Second page...
<?
include ("connection stuff");
$sql = "update stores set zone = '$zone', store_name = '$store_name', store_no = '$store_no', store_add = '$store_add', city = '$city', state = '$state' where store_name = '$store_name' and store_no = '$store_no'";
$sql_result = mysql_query($sql);
MYSQL_CLOSE();
?>
I have an "Edit Info" page which is not working quite right or at least not the way it seems like it should.
I make a query to bring up the info so the user can change it and then it goes to an update query.
It's working except there are two fields out of six which will not change. These two fields are also the ones the first query uses to find the results using the WHERE clause.
Neither of the two fields (store_name, store_no) are Unique or are Primary Keys. Is MySQL automatically locking them up or is there another possibility?
The code for the two pages follows. Thank you for any help.
Richard
...................................
First page...
<?
include ("connection stuff");
$sql = "select * from stores WHERE store_name = '$store_name' and store_no = '$store_no'";
echo $sql_result;
$sql_result = mysql_query($sql);
$msg = Mysql_num_rows($sql_result);
// start results formatting
echo "<p><table border='0' align='center'>";
echo "<tr bgcolor='#FFFFCC'>
<th>Zone</th>
<th>Store Name</th>
<th>Store #</th>
<th>Store Address</th>
<th>City</th>
<th>State</th>";
while ($row = mysql_fetch_array($sql_result)) {
$n1 = $row["zone"];
$n2 = $row["store_name"];
$n3 = $row["store_no"];
$n4 = $row["store_add"];
$n5 = $row["city"];
$n6 = $row["state"];
echo "<tr bgcolor='#99CCFF'>
<form method='post' action='edit_store2.php' method='post' onSubmit=\"return confirm('Edit store?');\">
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n1' name='zone' size='7'></td>
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n2' name='store_name' size='15'></td>
<td align='center'><input type='text' 'maxlength=100' value='http://www.phpbuilder.com/board/archive/index.php/$n3' name='store_no' size='10'></td>
<td align='center'><textarea 'maxlength=200' name='store_add'>$n4</textarea></td>
<td align='center' valign='middle'><input type='text' 'maxlength=100' size='15' value='http://www.phpbuilder.com/board/archive/index.php/$n5' name='city'></td>
<td align='center' valign='middle'>
<SELECT NAME=state>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/$n6'>$n6</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/CA'>CA</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/ID'>ID</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/OR'>OR</OPTION>
<OPTION VALUE='http://www.phpbuilder.com/board/archive/index.php/WA'>WA</OPTION>
</SELECT></td></tr>
<tr>
<td align='center' valign='middle'><input type='submit' value='http://www.phpbuilder.com/board/archive/index.php/Edit Store'></td>
</tr>
</form>
</tr>";
}
echo"</table></p>";
mysql_free_result($sql_result);
MYSQL_CLOSE();
}
?>
.............................
Second page...
<?
include ("connection stuff");
$sql = "update stores set zone = '$zone', store_name = '$store_name', store_no = '$store_no', store_add = '$store_add', city = '$city', state = '$state' where store_name = '$store_name' and store_no = '$store_no'";
$sql_result = mysql_query($sql);
MYSQL_CLOSE();
?>