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? 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? 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 Link to comment https://forums.phpfreaks.com/topic/9996-help-please/#findComment-37140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.