Querying info from one table based on info in another


Posted on 16th Feb 2014 07:03 pm by admin

Hi, I am currently trying to make a part for my user driven website where one user can subscribe to another and whoever they have subscribed to is echoed back on there profile page.

my users table structure is: id username password and my subscription table is: id user_id follow_id

Did you know?Explore Trending and Topic pages for more stories like this.
i am currently trying to query the logged in users subscriptions with this sql_query

$subsQuery = mysql_query("SELECT U.username FROM users AS U INNER JOIN subscription AS Sub.follow_id=U.id WHERE Sub.user_id=".$ID); $ID being the logged in users id.

However when trying to echo this on the page using this bit of php:

<? while ($subs = mysql_fetch_assoc($subsQuery)) { ?><br /><br />
<? echo $subs['username'] ?>

<? } ?>

it throws back this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/avince/public_html/users/user.php on line 53

Any help would be much appreciated!
No comments posted yet

Your Answer:

Login to answer
271 Like 7 Dislike
Previous forums Next forums
Other forums

unserialize help, getting errors
hi all ,
I got a form with 6 fields (2 input and 4 select box), when the page loads one block is

void* and sizeof()
Hi,

Using void* and sizeof is it possible to get the value of the object ?

I understan

ok i need to join all this pages to make 1 neat code
i have 5 pages that make up my tv guide it works 100% but i want to make it 1 page if i can or 2, i

problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

how do I show what a user have selected from a checkbox?
From my code below, how would i show which check boxes have been checked and which radio buttons sel

Email "$"
Hello!!

Any PHP guy with a bit of a knowledge in Flash ?

When I send a JPEG from flash

Something like an INI editor or a DelimitedText-Editor
Hi all,

Am very, very, very new to PHP and not sure if I should be posting this to a Javascri

Generate multilayered array from string.
ok so i have a string that looks like this:
Code: [Select]blog:edit_all,delete_all|users:edit_all

Forum tutorial
Im a beginner in PHP. Im making a forum(previous questbook, counter and few others) to learn. For no

Help on code output
My CODE:

Code: [Select] echo "<phone>".$line["phone"].&qu

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash