Jump to content

Listing data from a table based on selected value


stewart715

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