The information from the mySQL database is not showing up? The playerstats table is there ande there is a record called level in the table ... any other thoughts? echo "<table width=\"800\" border=\"0\">"; echo "<tr>"; echo "<td width=\"200\"><u>Player Name</u></td>"; echo "<td width=\"100\"><u>Player level</u></td>"; echo "<td width=\"225\"><u>Cash On Hand</u></td>"; echo "<td width=\"150\"><u>Gang Size</u></td>"; echo "<td width=\"125\"><center><u>Action</u></center></td>"; echo "</tr>"; $resultfight = mysql_query("SELECT * FROM playerstats WHERE level = 5 ORDER BY rand() LIMIT 15") or die(mysql_error()); $rowfight = mysql_fetch_array($resultfight); while($rowfight = mysql_fetch_array($resultfight)) { echo "<tr>"; echo "<td>" . $rowfight['name'] . "</td>"; echo "<td><b>" . $rowfight['level'] . "</b></td>"; echo "<td>\$" . $rowfight['gold'] . "</td>"; echo "<td>" . $rowfight['gang'] . "</td>"; echo "<td>Action button</td>"; echo "</tr>"; } echo "</table>"; Code (markup):
$resultfight = mysql_query("SELECT * FROM playerstats WHERE level = 5 ORDER BY rand() LIMIT 15") or die(mysql_error()); $rowfight = mysql_fetch_array($resultfight); while($rowfight = mysql_fetch_array($resultfight)) { echo "<tr>"; echo "<td>" . $rowfight['name'] . "</td>"; echo "<td><b>" . $rowfight['level'] . "</b></td>"; echo "<td>\$" . $rowfight['gold'] . "</td>"; echo "<td>" . $rowfight['gang'] . "</td>"; echo "<td>Action button</td>"; echo "</tr>"; } The issue seems to be in this bit of code here ... anybody?
Instead of running the mysql_query as you do now, do as follows: $resultfight = ("SELECT * FROM playerstats WHERE level = 5 ORDER BY rand() LIMIT 15") or die(mysql_error()); echo $resultfight; //this shows you how the query looks, and then you just copy that and run it through phpmyadmin to see what happens
$playerlevel = "5"; $resultfight = mysql_query("SELECT * FROM playerstats WHERE level = '$playerlevel' ORDER BY rand() LIMIT 15") or die(mysql_error()); $rowfight = mysql_fetch_array($resultfight); while($rowfight = mysql_fetch_array($resultfight)) { echo "<tr>"; echo "<td>" . $rowfight['name'] . "</td>"; echo "<td><b>" . $rowfight['level'] . "</b></td>"; echo "<td>\$" . $rowfight['gold'] . "</td>"; echo "<td>" . $rowfight['gang'] . "</td>"; echo "<td>Action button</td>"; echo "</tr>"; } echo "</table>"; ok this is what I have now and it still gives me a resource id #8 as the result for: echo $resultfight;
Did you try doing what I told you to do? Remove the "mysql_query" part, echo the SELECT-statement, and run it through the SQL-query in phpmyadmin?
Yes and it kicks out the proper records just the way I want it to.... I just can't seem to see why it wont from the page
Found the problem (stupid me) $resultfight = mysql_query("SELECT * FROM playerstats WHERE level = '$playerlevel' ORDER BY rand() LIMIT 15") or die(mysql_error()); [COLOR="Red"]$rowfight = mysql_fetch_array($resultfight); //remove this line[/COLOR] while($rowfight = mysql_fetch_array($resultfight)) { echo "<tr>"; echo "<td>" . $rowfight['name'] . "</td>"; echo "<td><b>" . $rowfight['level'] . "</b></td>"; echo "<td>\$" . $rowfight['gold'] . "</td>"; echo "<td>" . $rowfight['gang'] . "</td>"; echo "<td>Action button</td>"; echo "</tr>"; } echo "</table>"; Code (markup):
Seriously - if you don't know what you are talking about, why talk at all? I beg of you to try that in the query from the OP. See what happens, so to speak. Now, if you'd said: WHERE level = '5' It would have made so much more sense...