Jump to content

Archived

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

R1der

How Can I Echo From The Database?

Recommended Posts

ok basicly i want to echo all the names of people with a certon rank.

i.e

[code]<?if($user[uRank]=='5' or $user[uRank]=='4' or $user[uRank]=='3' ){?>[/code]
then it will echo all usernames with the user rank 5 , 4 and 3.

Does this make sence? lol

Share this post


Link to post
Share on other sites
well uh... well, assuming that your variables are holding the correct information, that would [i]technically[/i] work as is...

Share this post


Link to post
Share on other sites
[!--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

Share this post


Link to post
Share on other sites
Are you echoing the data from database or ..?

Btw.. What's the error showing ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks everyone for your replys to help.

thanks ToonMariner that worked great

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.