Jump to content

timetomove

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by timetomove

  1. 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

    please bear with me...

    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']."
    ";

    echo "Book Author: ".$req_reading_info['book_author']."
    ";


    ...........

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

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

    EXCEPT, it will only show the first record in the database (for that user).

    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?Huh

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

    Thanks,

    Tim
  2. 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

  3. PHP Freaks Forums
    Hello timetomove August 02, 2006, 03:37:05 pm *
    Show unread posts since last visit.
    Show new replies to your posts.
    Total time logged in: 3 minutes.
    News: We have DITCHED Invisionboard and converted to SMF. There are issues with signatures and some posts. Please do your best to help cleanup around here and move the conversion along.

      Home   Help Search Profile My Messages Members Logout
    PHP Freaks Forums > PHP Discussions > PHP SQL > Start new topic
    Using Date from PHP dropdown form in mySQL
    Hi there.

    How about this one then??
    I was wondering if anyone knew why this isnt working. I think its an error in my syntax, maybe a missing " or something?HuhHuh??

    While checking the availability of rental cars on a date.
    I'm trying to pass a choosen date from a dropdown form into a mySQL statement.
    The statement doesnt seem to be reading the $date variable. Any suggestions would be GREATLY appreciated.


    THE FORM:


    <form id="date_form" action="availability_action.php">
    <select name="day">
    <optgroup label="Day">
    <?php
    for ($i=1; $i <= 31; $i++)
      {
      echo "<option value=\"$i\">$i</option>";
      }
    ?>
    </optgroup>
    </select>
    <select name="month">
    <optgroup label="Month">
    <?php
    for ($i=1; $i <= 12; $i++)
      {
      echo "<option value=\"$i\">$i</option>";
      }
    ?>
    </optgroup>
    </select>
    <select name="year">
    <optgroup label="Year">
    <?php
    for ($i=2000; $i <= 2010; $i++)
      {
      echo "<option value=\"$i\">$i</option>";
      }
    ?>
    </optgroup>
    </select>



    <input type="submit" value="Go!" />
    </div>
    </form>


    THE ACTION:

    $date = $_POST['year'].str_pad($_POST['month'], 2, '0', STR_PAD_LEFT).str_pad($_POST['day'], 2, '0', STR_PAD_LEFT);


    $results = mysql_query("SELECT car
    FROM car_table
    LEFT JOIN booking_table ON car_table.car = booking_table.car
    WHERE $date NOT
    BETWEEN booking_table.start
    AND booking_table.end")

    OUTPUT RESULTS:

    while ($row = mysql_fetch_assoc($results))
      {
      $output .= '<tr>'."\n";
      $output .= '<td class="col_1">'.$row['car'].'</td>'."\n"; 
      $output .= '</tr>'."\n";
      }


    The output is showing ALL the cars in the car_table and not paying any attention to my $date variable!


    I hope Ive described my problem clearly and really would be most grateful if anyone could give me any pointers. I tried concetenating .'115959' onto the end of the $date parameters as my dates are in yyyymmddhhmmss format but I wasnt sure if that was neccessary.. it didnt do anything.

    Thanks,

    Tim

×
×
  • 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.