Jump to content


Photo

Listing data from a table based on selected value


  • Please log in to reply
3 replies to this topic

#1 stewart715

stewart715
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts

Posted 19 October 2006 - 11:24 PM

okay say i have this data

uid  bid    rid
2      5        0
5      7        1
7      8        1 
8      7        0
7      2        0
4      3        1
7      4        1

I need a script that will print ALL the bid's where the uid is 7 and the rid is 1...how would i do that?

the result from the above table should be 4 and 8, for example.

#2 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 19 October 2006 - 11:44 PM

mysql_query("SELECT `bid` FROM `table` WHERE `uid` = '7' AND `rid` = '1'") or die(mysql_error());


#3 stewart715

stewart715
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts

Posted 20 October 2006 - 12:09 AM

hmm i'm getting Resource ID #3

There is a uid with 7 and a received of 1 in the same row in the actual table..but idk why it isn't working

<?php
$link = mysql_connect("localhost","thepdcom_popnew","PASSWORD");
mysql_select_db("thepdcom_popnew",$link);
$query = mysql_query("SELECT buddy FROM buddylist WHERE uid = '7' and received = '1'") or die(mysql_error());
mysql_query($query);
$result = mysql_num_rows($query); 
print $query;
?>


#4 .josh

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

Posted 20 October 2006 - 12:54 AM

<?php
$link = mysql_connect("localhost","thepdcom_popnew","PASSWORD");
mysql_select_db("thepdcom_popnew",$link);
$query = mysql_query("SELECT buddy FROM buddylist WHERE uid = '7' and received = '1'") or die(mysql_error());
mysql_query($query);
$result = mysql_num_rows($query); 
if ($result > 0) {
   while ($list = mysql_fetch_array($query)) {
      echo "{$list['buddy']} <br>";
   }
}
?>

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 :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users