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

how to configure ADS in ABAP instance
Hi All,

I am working on r/3 4.7 ABAP system.Can we configure ADS(adobe document services)

Concatenate two strings ???
I have string one $string1 and another $string2.

How to concatenate (add) both of them $str

Using system() and bringing back the results
I am aware that you can use system() within PHP to execute system commands, but I was wondering if t

error with opendir
when i do this

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($han

To change the name of label on SAP screen XK02.
Hi All,

Can one suggest me how to change the label of an input field of a sap standard s

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

Get content from table into a list, without repeating.
Alright this is kinda an odd thing, so I need some help.

I have a table "quote" wit

Download Image from URL and Upload it
Ok, I have been googling for the last 1/2 hour trying to figure this out, Most likely I'm just not s

Create PHP table grid help, please
I have a MySQL database setup, now it's time for the table (gridview) design in php. Here's the prob

how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?

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