brown2005 Posted May 19, 2006 Share Posted May 19, 2006 $query = "SELECT * FROM table order by amount desc";$result = mysql_query($query) or die (mysql_error());$num = mysql_num_rows($result);$current_price = 0;echo "<table cellpadding=5 cellspacing=0>";for($i=0;$i<$num;$i++){$row = mysql_fetch_array($result);if($row['amount'] != $current_price){echo "<tr><td>".$row['amount']."</td></tr>".;$current_price = $row['amount'];}echo "<tr><td>".$row['text']."</td></tr>".;}echo "</table>";i have the above code but nothing comes out, any ideas why not please? Quote Link to comment https://forums.phpfreaks.com/topic/9996-help-please/ Share on other sites More sharing options...
hitman6003 Posted May 19, 2006 Share Posted May 19, 2006 Rather than using a for loop, use a while loop, then you don't need the extra $num:[code]<?php$query = "SELECT * FROM table order by amount desc";$result = mysql_query($query) or die (mysql_error());$current_price = 0;echo '<table cellpadding="5" cellspacing="0">';while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if($row['amount'] != $current_price) { echo " <tr> <td>".$row['amount']."</td> </tr>"; $current_price = $row['amount']; } echo " <tr> <td>".$row['text']."</td> </tr>";}echo "</table>";?>[/code]Also, why did you have a period (.) at the end of your echo lines, after the closing quote, but before the semicolon? Quote Link to comment https://forums.phpfreaks.com/topic/9996-help-please/#findComment-37137 Share on other sites More sharing options...
brown2005 Posted May 19, 2006 Author Share Posted May 19, 2006 cheers sorted.. thanks mate Quote Link to comment https://forums.phpfreaks.com/topic/9996-help-please/#findComment-37140 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.