$query_lots="SELECT * FROM lots_new WHERE lot_sku_id='$curr_key'";
$lots_result=mysql_query($query_lots) or die(mysql_error());
$row1 = mysql_fetch_array($lots_resut, MYSQL_NUM)) ;
if( $row1 ) {
//process row 1, if any
// process subsequent rows, if any
while ($row = mysql_fetch_array($lots_resut, MYSQL_NUM)) { //
printf("ID: %s Name: %s", $row[0], $row[1]);
}
}
But better, make your process handle rows uniformly, by making the single while do something like this:
$query_lots="SELECT * FROM lots_new WHERE lot_sku_id='$curr_key'";
$lots_result=mysql_query($query_lots) or die(mysql_error());
// process ALL rows, if any
while ($row = mysql_fetch_array($lots_resut, MYSQL_NUM)) { //
printf("ID: %s Name: %s", $row[0], $row[1]);
//print row close html, followed immeditely by opening a new row:
printf("</tr> <tr>");
}
}
//terminate the last row:
printf("</tr>");
And to make sure this works correctly, you need an ORDER BY on your query.mysql_escape_string( $curr_key ) to prevent SQL injection attacks, right?You are not logged in, either login or create an account to post comments
posted by GilloD at 5:26 PM on June 27