View Full Version : help with query

02-15-2009, 01:25 PM
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:

$text .= "text in here";


so ive tried using these to display the user's chosen lottery numbers.

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

02-15-2009, 04:14 PM
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...