Jump to content

Please: multiple records for a session variable - thanks!


timetomove

Recommended Posts

Any help appreciated.

I'm working within the framework of a object orientated login script using sessions.

Basically, once a user is logged in I would like to list all of the books_titles and book_authors(for example) that are held in the database table: readinglist for that logged in user of the website
[b]
please bear with me...[/b]

to do this is have called the function, getReadinglistInfo($username) which does the select query for that user.

the session cookie is recognised by setting variables in a seperate file(session.php) like:

var $readinglist = array();
var $booktitle;
var $bookauthor;


in the
checkLoginfunction()
i added:
$this->readinginfo = $database->getReadinglistInfo($username);
$this->booktitle = $this->readinginfo['book_title'];
$this->bookauthor = $this->readinginfo['book_author'];

.........

and then on the actual web page i used:

$req_user = trim($_GET['user']);

/* Display requested garden information */
$req_reading_info = $database->getReadinglistInfo($req_user);

echo "Book Title: ".$req_reading_info['book_title']."<br />";

echo "Book Author: ".$req_reading_info['book_author']."<br />";


...........

This then gives the FIRST book title and author for that user in my readinglist table.

I havent put all the code here but [b]I hope you get the idea[/b].
I probably havent copied it down here very accurately either but...
It works GREAT on my website.....

[b][u]EXCEPT, it will only show the first record in the database (for that user).[/u][/b]

What I would like to do is loop through all the book titles and authors(for the user)
I dont know if i need an array within an array????

It would be great if someone who understands this could advise on how its best done.

Thanks,

Tim
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.