Jump to content

Archived

This topic is now archived and is closed to further replies.

xyn

SQL help

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]

Share this post


Link to post
Share on other sites
methinks $data["rep"] needs to be  {$data["rep"]}

also are you afraid of escaping quotation marks or something? you could do that whole thing without periods

Share this post


Link to post
Share on other sites
Nope i got errors

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Try miiiiiiiiiine. :)

Dude, you don't use { } when dealing with single quotes.

Share this post


Link to post
Share on other sites
I have tried yours :P

i got this:
Warning: Wrong parameter count for mysql_fetch_row() in /home/zroxxco/public_html/Zone/Members.php on line 52

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Thanks pix. btw when i tried array it stayted the same
although its probably becuase i done this:
'.$data['id'][0].' rofl, but works now :]
thanks

Share this post


Link to post
Share on other sites
Lol, that [i]might[/i] cause a problem.

Glad you got it worked out.

Share this post


Link to post
Share on other sites

×

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.