Jump to content

How Can I Echo From The Database?


R1der

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
Link to comment
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
Link to comment
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.
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.