Jump to content

How Can I Echo From The Database?


R1der

Recommended Posts

[!--quoteo(post=389162:date=Jun 29 2006, 03:27 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 29 2006, 03:27 AM) [snapback]389162[/snapback][/div][div class=\'quotemain\'][!--quotec--]
well uh... well, assuming that your variables are holding the correct information, that would [i]technically[/i] work as is...
[/quote]

yes all that info is correct. but what i ment was how would i echo the usernames? i have tried a few ways but get errors. but i am still rather new to php
OK this is how i would do it....
[code]
<?php
// create a comma separated string of ranks to display.
$ranks = "3,4,5";

$qry = "SELECT * from `users` WHERE `uRank` IN (" . $ranks . ") ORDER BY `username` ASC";
$qry = mysql_query($qry);

?>
<ul>
<?php
while ($row = mysql_fetch_assoc($qry) )
{
?>
<li><?php echo $row['username']; ?></li>
<?php
}
?>
</ul>
<?php
[/code]

Now you can put all the html to control the look around the echo statement..

I have used a list but if you are displying other information associated with that user then a table would be appropriate.

Archived

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

×
×
  • 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.