I have two tables;
Books ,book_id ,mbook_id (Relation with mbook_id in the master_books table) ,org_id ,book_rating
master_books ,mbook_id ,book_name ,book_authors ,book_summary ,book_pub_date ,book_ISBN10 ,book_ISBN13 ,book_image
Now the idea is that there are a collection of books in the master_books table, but say there were 3 libraries who all had the same book. Instead of having 3 entries of the book the books table just references the master_books table id for the book information.
To start with i've set up a simple query to get all books, like so;
$result = mysqli_query($link, "SELECT books.book_id, master_books.book_name, master_books.book_image FROM books JOIN master_books ON master_books.mbook_id WHERE org_id='" . $org_id . "'");
I'm using the following to output the data;
$books = mysqli_fetch_array($result);
foreach($books as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
The result is follows;
Key=0, Value=1
Key=book_id, Value=1
Key=1, Value=Picturepedia: 15 Plants (Picturepedia)
Key=book_name, Value=Picturepedia: 15 Plants (Picturepedia)
Key=2, Value=9780751350852.jpg
Key=book_image, Value=9780751350852.jpg
I'm trying to figure out why it duplicates with Key=0 and then Key=book_id and so on. The lines beginning with Key=0, Key=1, Key=2 shouldn't be there