Page 1 of 1
[SOLVED] sql help
Posted: Sun Jul 11, 2004 8:52 pm
by fresh
man I promise I'm almost getting this sql query stuff, however, I still need some help:
Code: Select all
<?php
$them=@mysql_query("select * username from users");
echo " <img src='http://blah.com/devil.gif'> <a href='whois/".$them.".htm' style='text-decoration:none'><font color=black>".$them."</font></a><br>";
?>
theres my attempt, it's not working, just showing one entry with no name... how would I enumerate the entire column??? There is 79 entries, please help.... thanks in advance

Posted: Sun Jul 11, 2004 8:58 pm
by feyd
you'll get "Resource id#6" or something similar... you need to use one of the fetching functions:
Code: Select all
<?php
$them=@mysql_query("select * username from users") or die(mysql_error());
while($row = mysql_fetch_assoc($them))
{
echo '<pre>'.htmlentities(print_r($row,true),ENT_QUOTES).'</pre>';
echo " <img src='http://blah.com/devil.gif'> <a href='whois/".$row['someelement'].".htm' style='text-decoration:none'><font color=black>".$row['someelement']."</font></a><br>";
}
?>
hey
Posted: Sun Jul 11, 2004 9:15 pm
by fresh
thank you... I had to fix it a bit, but it still worked like I wanted, and was a big help to me, so thanks feyd, I appreciate the help

Posted: Sun Jul 11, 2004 10:25 pm
by d3ad1ysp0rk
I'm still confused. How does this work:
Isn't it * (all) or username (specific column)? Not both?
Posted: Sun Jul 11, 2004 10:27 pm
by feyd
it probably wouldn't., if anything, it'd try to alias all fields to username..

Posted: Sun Jul 11, 2004 10:49 pm
by d3ad1ysp0rk
ok.. well.. then.. *points out that even the script you gave him still has that query in it*
Fresh, is that what you're still using?
hey
Posted: Mon Jul 12, 2004 5:24 am
by fresh
no I took that * <------- out... it didnt seem to do anything bad, just realised it didnt need to be there, so I edited it out, I also changed this:
Code: Select all
<?php
$them=@mysql_query("select * username from users") or die(mysql_error());
while($row = mysql_fetch_assoc($them))
{
echo '<pre>'.htmlentities(print_r($row,true),ENT_QUOTES).'</pre>';
echo " <img src='http://blah.com/devil.gif'> <a href='whois/".$rowї'someelement'].".htm' style='text-decoration:none'><font color=black>".$rowї'someelement']."</font></a><br>";
}
?>
to this:
Code: Select all
<?php
$them=@mysql_query("select blah from bleb") or die(mysql_error());
while($row = mysql_fetch_assoc($them))
{
echo "
<img src='http://blah.com/devil.gif'>
<a href='whois/".$row['someelement'].".htm' style='text-decoration:none'>
<font color=black>".$row['someelement']."</font></a>";
}
?>
one problem though, I added another query to get the last login time, and when I use pics as is above, I have to use the same one, or otherwise it wont get like the last 6 entries??? It's weird, I don't know why it's doing that?? Would be nice to place a different pic in the last login table cells, but, for now it's not that important, I guess... anyway, that's what I did, hope it helped...
