Complete newbie - have battled with this all day and going nowhere - completely stumped so throwing myself on your mercy!!
I have a simple form which has a select drop down populated from my sql database. When I hit submit nothing seems to get passed to the hidden field in the next page.
My code for the form is as follows:
<form action="selectday.php" method="get">
<select>
<?php
//connect to MySQL
$connect = mysql_connect("localhost","root","") or
die ("Could not connect to database.");
//choose the database
mysql_select_db("lakeside");
//Query from database
$sql="SELECT year_id, year FROM years";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$year_id=$row["year_id"];
$year=$row["year"];
$options.="<OPTION VALUE=\"$year_id\">".$year.'</option>';
}
?>
<SELECT NAME=year_id>
<OPTION VALUE=0>Choose Year Group
<?=$options?>
</SELECT>
<input type="submit" />
</select>
</form>
I believe by using GET I should see the data passed in the url?? Any advice would be great!
Pass variable to next page using GET
Moderator: General Moderators
Re: Pass variable to next page using GET
It might have something to do with the invalid HTML you're using. What's up with that lone <select>?
Re: Pass variable to next page using GET
You Sir are a legend. I've tried several ways of doing this today and at some point during cutting/pasting code and changing things must have left that lone select there. Think you've cracked it. Thanks 