Jump to content

SQL help


xyn

Recommended Posts

Hi,
This is very minor but it's quite irritating as it wont work. I'm trying to choose certain rows from my database as it is quicker to load pages and gather information, however my problem is i get blank spaces.

code:
[code=php:0]<?
$result = mysql_query("SELECT id,user,rank,rep FROM accounts ORDER BY 'id' ASC");
      while($data = mysql_fetch_row($result)){
     
      echo '<tr>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data["user"].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data["rank"].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data["rep"].'</font></td>
    <td width="25%" align="center" height="20">
    <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data["id"].'">PM</a> ]</font></td>
  </tr>';
      }
?>[/code]
Link to comment
Share on other sites

Try this:
[code]
<?php
$result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC");
while ($data = mysql_fetch_row($result, MYSQL_NUM)) {
    echo '<tr>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td>
    <td width="25%" align="center" height="20">
    <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td>
  </tr>';
}
?>[/code]
Link to comment
Share on other sites

Oops, I'm stupid. I used mysql_fetch_row() instead of mysql_fetch_array(). I never use the first function, so I have no idea how it came into my head...oh, that's because it's what you were using. That was probably your problem.

Try this:

[code]
<?php
$result = mysql_query("SELECT id, user, rank, rep FROM accounts ORDER BY id ASC");
while ($data = mysql_fetch_array($result, MYSQL_NUM)) {
    echo '<tr>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[1].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[2].'</font></td>
    <td width="25%" align="center" height="20">
    <font face="Verdana" size="1" color="#54A800">'.$data[3].'</font></td>
    <td width="25%" align="center" height="20">
    <font size="1" face="Verdana" color="#54A800">[ <a href="contact.php?id='.$data[0].'">PM</a> ]</font></td>
  </tr>';
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.