lmninfo Posted March 19, 2009 Share Posted March 19, 2009 I'm trying to pull information from my database and display the information in table format .. the table and information looks ok however the very first line after the table headers is screwy .. here is what I have code wise: <?php //lists all users close in rank to your range include 'connect.php'; session_start(); ?> <?php if (isset($_SESSION['player'])) { $player=$_SESSION['player']; $getplayerpoints="SELECT * from km_users where playername='$player'"; $getplayerpoints2=mysql_query($getplayerpoints) or die("Could not get player points"); $getplayerpoints3=mysql_fetch_array($getplayerpoints2); $numrows="SELECT * from km_users where score>='$getplayerpoints3[score]'"; $numrows2=mysql_query($numrows) or die("Could not grab rows"); $numrows3=mysql_num_rows($numrows2); $total="SELECT * from km_users"; $total2=mysql_query($total) or die("Could not get users"); $total3=mysql_num_rows($total2); $numrows4=$numrows3+20; if($numrows4>=$total3) { $numrows4=$total3; } $numrows5=$numrows3-20; if($numrows5<0) { $numrows5=0; } print "<center>Players close to you in rank, your name is in red"; $getrank="SELECT * from km_users order by score desc limit $numrows5,$numrows4"; $getrank2=mysql_query($getrank) or die("Could not fetch ranks"); print "<table border='1'>"; print "<tr><td>Emperor</td><td>Score</td><br>"; while($getrank3=mysql_fetch_array($getrank2)) { if($getplayerpoints3[iD]==$getrank3[iD]) { print "<td><font color='red'>$getrank3[playername]</font></td><td><font color='red'>$getrank3[score]</font></td></tr>"; } else { print "<td>$getrank3[playername]</td><td>$getrank3[score]</td></tr>"; } } print "</table>"; } else { print "Not Logged in"; } ?> After the information is pulled from the table, the lines emperor and score schould be at the top of the table but instead of dropping to the next line with the first player's empirename and score the empirename and score are on the same line as the emperor and score Thanks Quote Link to comment Share on other sites More sharing options...
ram4nd Posted March 19, 2009 Share Posted March 19, 2009 <?php //lists all users close in rank to your range include 'connect.php'; session_start(); ?> <?php if (isset($_SESSION['player'])) { $player=$_SESSION['player']; $getplayerpoints="SELECT * from km_users where playername='$player'"; $getplayerpoints2=mysql_query($getplayerpoints) or die("Could not get player points"); $getplayerpoints3=mysql_fetch_array($getplayerpoints2); $numrows="SELECT * from km_users where score>='$getplayerpoints3[score]'"; $numrows2=mysql_query($numrows) or die("Could not grab rows"); $numrows3=mysql_num_rows($numrows2); $total="SELECT * from km_users"; $total2=mysql_query($total) or die("Could not get users"); $total3=mysql_num_rows($total2); $numrows4=$numrows3+20; if($numrows4>=$total3) { $numrows4=$total3; } $numrows5=$numrows3-20; if($numrows5<0) { $numrows5=0; } print "<center>Players close to you in rank, your name is in red"; $getrank="SELECT * from km_users order by score desc limit $numrows5,$numrows4"; $getrank2=mysql_query($getrank) or die("Could not fetch ranks"); print "<table border='1'>"; print "<tr><td>Emperor</td><td>Score</td><br>"; while($getrank3=mysql_fetch_array($getrank2)) { if($getplayerpoints3[iD]==$getrank3[iD]) { print "<tr><td><font color='red'>$getrank3[playername]</font></td><td><font color='red'>$getrank3[score]</font></td></tr>"; } else { print "<tr><td>$getrank3[playername]</td><td>$getrank3[score]</td></tr>"; } } print "</table>"; } else { print "Not Logged in"; } ?> You forgot to start with <tr>. Quote Link to comment Share on other sites More sharing options...
sloth456 Posted March 19, 2009 Share Posted March 19, 2009 plus I think you made a mistake on this line print "<tr><td>Emperor</td><td>Score</td><br>"; Shouldn't that be print "<tr><td>Emperor</td><td>Score</td></tr>"; You had <br> instead of </tr> at the end Quote Link to comment 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.