GreenSmurf Posted September 1, 2009 Share Posted September 1, 2009 I have some code where no matter how I sort the info- the first result is ignored in the display. If anyone can see something wrong in the code let me know. Thanks. $lastditch_result = mysql_query("SELECT * FROM customers ORDER BY Last,First"); $lastditch_row = 0; if ($lastditch_row <= mysql_fetch_array($lastditch_result)) { beginPrettyTable("6", "$lCustomers"); beginBorderedTable("6"); echo ("<tr>\n"); echo ("<td><b>$lName</b></td> <td><b>$lCompany</b></td><td><b>$lAddress</b></td> <td><b>$lEmail</b></td>\n <td><b>$lBalance</b></td> <td><b>$lActions</b></td>\n </tr>\n"); while ($lastditch_row = mysql_fetch_array($lastditch_result)) { if($class == "odd") { $class = "even"; } else { $class = "odd"; } if($lastditch_row["Balance"] >= 0) { $bal_class = "positive"; } else { $bal_class = "negative"; } printf("<tr class='$class'>\n<td align='left'><a href='%s?CustomerID=%s'>%s %s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td><div class='$bal_class'>%.4f</div></td> <td align='center'><a href='%s?CustomerID=%s'><img src='images/edit.gif' width=24 height=24 border=0></a><a href='confirm.php?action=deletecustomer&CustomerID=%s'><img src='images/delete.gif' height=24 width=24 border=0 alt='$lDelete'></a></td></tr>\n", $PHP_SELF, $lastditch_row["CustomerID"], $lastditch_row["First"], $lastditch_row["Last"], $lastditch_row["Company"], $lastditch_row["Address"], $lastditch_row["Email"], $lastditch_row["Balance"], $PHP_SELF,$lastditch_row["CustomerID"],$lastditch_row["CustomerID"]); } endPrettyTable(); endBorderedTable(); } else { echo ("<tr><td>$lNoProfilesFound...</td></tr>\n"); } -GreenSmurf Quote Link to comment https://forums.phpfreaks.com/topic/172640-solved-first-result-in-array-being-ignored/ Share on other sites More sharing options...
btherl Posted September 1, 2009 Share Posted September 1, 2009 This line: if ($lastditch_row <= mysql_fetch_array($lastditch_result)) { will fetch the first result row, and then ignore it. Probably you want: if (mysql_num_rows($lastditch_result) > 0) { Quote Link to comment https://forums.phpfreaks.com/topic/172640-solved-first-result-in-array-being-ignored/#findComment-910001 Share on other sites More sharing options...
GreenSmurf Posted September 1, 2009 Author Share Posted September 1, 2009 OMGLOL I WUZ ROFLPWN'd. I only kid. I do feel stupid however for missing that one. Thanx man. -GreenSmurf Quote Link to comment https://forums.phpfreaks.com/topic/172640-solved-first-result-in-array-being-ignored/#findComment-910007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.