|
Posted by MattMika on 09/16/05 20:46
I have form buttons in a table populated by a query. For some reason the
first result will not redirect properly. When I click on submit the
location on the status bar says thisdir/... rather than
thisdir/editproduct.php.
All other results redirect properly to editproduct.php. However I order the
results the first one never works and all the rest do.
Here's my code;
$query = "SELECT * FROM `products` ORDER BY `product_model` ASC";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result);
$i=0;
while ($i < $num) {
$product_id=mysql_result($result, $i, "product_id");
$product_model=mysql_result($result, $i, "product_model");
$product_type=mysql_result($result, $i, "product_type");
$product_name=mysql_result($result, $i, "product_name");
$product_descript=mysql_result($result, $i, "product_descript");
$product_price=mysql_result($result, $i, "product_price");
// Alternating row colors
$bgcolor=($i % 2) ? "FFFFFF" : "D5DFEB";
echo "<tr bgcolor=\"$bgcolor\">
<td class=\"list\" align=\"left\" nowrap>$product_model</td>
<td class=\"list\" align=\"left\" nowrap>$product_name</td>
<td class=\"list\" align=\"left\" nowrap>$product_descript</td>
<td class=\"list\" align=\"left\" nowrap>$product_type</td>
<td class=\"list\" align=\"left\" nowrap>$product_price</td>
<form METHOD=\"post\" ACTION=\"editproduct.php\"><td class=\"list\"
align=\"center\" nowrap><input type=\"hidden\" name=\"editproduct\"
value=\"$product_id\"><input src=\"../images/button_edit.jpg\"
type=\"image\" value=\"Edit\"></td></form>
<form METHOD=\"post\" ACTION=\"$_SERVER[PHP_SELF]\" onsubmit=\"return
confirm('Are you sure you want to delete this product?');\"><td
class=\"list\" align=\"center\" nowrap><input type=\"hidden\"
name=\"deleteproduct\" value=\"$product_id\"><input
src=\"../images/button_delete.jpg\" type=\"image\"
value=\"Delete\"></td></form>
</tr>";
$i++;
}
Funny thing is I use this same piece of code with a different query and it
works just fine...
Can someone point out the problem?
Thanks
[Back to original message]
|