Jump to content

Archived

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

stewart715

Listing data from a table based on selected value

Recommended Posts

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.

Share this post


Link to post
Share on other sites
mysql_query("SELECT `bid` FROM `table` WHERE `uid` = '7' AND `rid` = '1'") or die(mysql_error());

Share this post


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

[code]
<?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;
?>
[/code]

Share this post


Link to post
Share on other sites
[code]
<?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>";
  }
}
?>
[/code]

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.