Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: help with query

  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    help with query

    Im having a few problems displaying results of a query.

    Im currently developing a text based browser game, it has been made ready to play but I am introducing a 'lottery' to the game. So far I have made a script to empty the db table and then insert 6 randomly generated numbers, this script is on a cron to run every day. I have also done the user's input form where they pick 6 numbers and are saved to the db. Ive done all the validation to make sure they don't pick the same number twice and they have enough credits to buy the lotto ticket. I am currently working on a page where they can view all the tickets they have purchased.

    I have the basic U.I on the left hand side and at the top of the page, with the current page displayed in the middle of the screen.

    For all the other pages these codes are used:

    PHP Code:
    $text .= "text in here"
    and
    PHP Code:
    print_page("$text); 
    so ive tried using these to display the user's chosen lottery numbers.

    PHP Code:
    $db db_connect($database_host$database_user$database_password$database$database_persistent);

    dbn(__FILE__,__LINE__,"select no1, no2, no3, no4, no5, no6 from lotto_tickets where login_id = '$user[login_id]' and login_name = '$user[login_name]'");
    $text .= "<center>Tickets purchased so far:</center><br><br><table><tr><td>";
    $text .= "No. 1</td><td>No. 2</td><td>No. 3</td><td>No. 4</td><td>No. 5</td><td>No. 6</td></tr>";
    $text .= "<tr><td>$no1</td><td>$no2</td><td>$no3</td><td>$no4</td><td>$no5</td><td>$no6</td></tr>";
    $text .= "</table>"
    im probably being really stupid here and the code is probably completely wrong for what I want to do.

    At the moment all Im getting is the column titles no entries from the db.

    Of course there could be more than one entry from the user so the table would have to add another row for each entry.


    Any help would be greatly appreciated.

  • #2
    Regular Coder lokeshshettyk's Avatar
    Join Date
    Aug 2008
    Location
    On the way to the moon!
    Posts
    157
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Few basic debugging required

    1) echo your query and ensure you get the reqired values passed to the query from the variables

    2) then, run this printed query on your DB and see if you get expected result...
    _______________________________________________________________________________________
    Thank the user for his/her helpful post by clicking on the button below the post :)

    Cheers :)
    ~ LSK ~


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •