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

Check premium expire
Hi,

I am making a simple file hosting site and want to check if users premium subscriptions h

Save username into DB
OkaY so I got my blog to actually save the posts and whatever, all I need now is for it to keep the

Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

Page Reload
I am having issues getting a page to reload after I submit data to a database. This form should inp

upgrade from 4.7 to ECC 6.0
Hi all,
we are going to do an upgrade from R/3 4.7 to ECC 6.0. I need to know if i can find som

Is it possible to stop reservation creation in PM Order?
Hi All,

Is it possible to stop reservation creation in PM Order?

Thanks in adv

Load Animated Image while cache is serve
I have a page that loads up using cache and took about 1 to 2 minutes before it loads to the page. <

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

add to sql result
ok see rite now my sites hit counter is counted from the mysql visitor log i need to clear it aft

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