I have two tables books and users. books has a column id
and users has a column called book_id
. users table is populated by info about users who bought books from the store including the column book_id
which referees to the id
from books table.
My questions is, I have been trying to do this but with no success.
$query = mysql_query("SELECT * FROM books, users WHERE books.id='$id' OR users.id='$id' ");
while($row = mysql_fetch_array($query)){
$info .= $row[0] . " " . $row[1] . "<br/>";
}
echo $info;
Table books has some data but users is empty and I am getting nothing as an output!!! What am I missing??
Additional attempts:
SELECT * FROM books, users WHERE books.id='$id'
returns empty results
SELECT * FROM books WHERE books.id='$id'
returns 5 rows