Forum Moderators: mack

Message Too Old, No Replies

Form Select Elements and PHP

Passing Select Element Values...

         

sainty

5:36 am on Oct 31, 2004 (gmt 0)

10+ Year Member



Hi everyone, this is my first post, so be gentle ;)

I'm creating a website, that allows me and a friend to review games we've played. Everything was going well untill I got to this point:

When I want to add a review, I goto a page that contains a LIST of games currently residing in the database. I then want to be able to select that game, from the list then carry on and add a review to it.

So far it looks like this:

<form action='addrev.php' method='post'>
<select name="games" size="1">
<?php
$sql = "SELECT * FROM Games";
$result = mysql_query($sql);

while ($game = mysql_fetch_row($result)) {
echo("
<option value='$game[0]'>$game[1]</option>
");
}
?>
</select>
<p><input name="Submit" type="submit" value="Review">
</form>

This generates the list perfectly. However, once I select my game and click Submit... I cannot retrieve the information I want.

I want the value to be passed to the next page, so that when I add the review the value(which is an integar) is added to the reviews database.

Example:

$SQL = "INSERT INTO Reviews (reviewID, userID, gameID) VALUES ( 'NinjaGaiden', '23' , '$value' )";

But, $value is never assigned...

If you can translate my jibberish, then please, I emplore you - Help :)

Thanks alot,

Sainty.

charlier

6:38 am on Oct 31, 2004 (gmt 0)

10+ Year Member



The value should be in the variable $games (if globals are on) or in $_POST["games"] if not. Put a phpinfo() statement in your code to see all the varibales passed to your acton page.

Welcome to Webmaster World

sainty

7:00 am on Oct 31, 2004 (gmt 0)

10+ Year Member



Thanks so much! As soon as I read your post, I hit myself in the head lol :-)