I have some information in my database like ‘author’, ‘book’ etc., that are all related to a ‘note_id’, which is related to a ‘user’. I query the DB for the note id and I get this back:
note_id assoc array
Array ( [0] => 32 ) Array ( [0] => 31 ) Array ( [0] => 33 ) Array ( [0] => 34 ) Array ( [0] => 35 ) Array ( [0] => 36 ) Array ( [0] => 37 ) Array ( [0] => 38 ) Array ( [0] => 39 ) Array ( [0] => 40 ) Array ( [0] => 41 ) Array ( [0] => 42 ) Array ( [0] => 43 ) Array ( [0] => 44 ) Array ( [0] => 45 ) Array ( [0] => 46 )
What I am trying to do is to use all of these values to grab each book review (with author, book, etc.) and then display it to the user in order, one by one.
What’s the next step for me to be able to do this?
Here is the code I am using:
<?php
//Starting session
session_start();
//Includes mass includes containing all the files needed to execute the full script
//Also shows homepage elements without customs
include ('includes/mass.php');
//Set the session variable
$username = $_SESSION['username'];
//Check to see if logged in
if (isset($username)) {
//Check all databases assoc with the notes for username submissions
$sql_for_username_submission = "SELECT note_id FROM notes WHERE user = '$username'";
$get_data = mysql_query($sql_for_username_submission);
while ($data_row = mysql_fetch_assoc($get_data)) {
$name_id = $data_row;
}
}
?>
Have you considered looking into using joins so that you could have MySQL automatically lookup the data for you without separate queries?