Jump to content


Photo

How Can I Echo From The Database?


  • Please log in to reply
5 replies to this topic

#1 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 29 June 2006 - 08:26 AM

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

i.e

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

Does this make sence? lol


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 29 June 2006 - 08:27 AM

well uh... well, assuming that your variables are holding the correct information, that would technically work as is...
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 29 June 2006 - 08:40 AM

[!--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) View Post[/div][div class=\'quotemain\'][!--quotec--]
well uh... well, assuming that your variables are holding the correct information, that would technically 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

#4 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 29 June 2006 - 08:42 AM

Are you echoing the data from database or ..?

Btw.. What's the error showing ?

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 29 June 2006 - 08:48 AM

OK this is how i would do it....
<?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

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.
follow me on twitter @PHPsycho

#6 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 29 June 2006 - 08:56 AM

Thanks everyone for your replys to help.

thanks ToonMariner that worked great




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users