Sorry Cups, I’m affraid not.
I don’t want to take up too much more of your time but if you can bear with me:–
I have two files
- tester.php - which populates the dropdown list from the database
- index3.php - which tries to select all the competition details from the database
tester.php
<html>
<head>
</head>
<body>
<form action= “index3.php” method=“post”>
<?php
$server=“localhost”;
$username=“root”;
$password=“”;
$link=mysql_connect($server, $username, $password) or die ("Cannot connect to mysql server: ".mysql_error());
$dbname = ‘golf_society’;
mysql_select_db($dbname, $link) or die ("Cannot connect to database: ".mysql_error());
$query=“SELECT competitionname, id, competitiondate FROM competition order by competitiondate”;
$result = mysql_query ($query) or die (‘error submitting’);
echo “<select name=‘competitionname’>”;
while($drop=mysql_fetch_array($result)){
//data stored in $drop
echo “<option value=$drop[id]>$drop[competitionname] $drop[competitiondate]</option>”;
}
echo “</select>”;
?>
<input type=“submit” value=“Submit”>
</form>
</body>
</html>
index3.php
?php
$competition = $_POST[‘competitionname’];
$server=“localhost”;
$username=“root”;
$password=“”;
$link=mysql_connect($server, $username, $password) or die ("Cannot connect to mysql server: ".mysql_error());
$dbname = ‘golf_society’;
mysql_select_db($dbname, $link) or die ("Cannot connect to database: ".mysql_error());
$result = mysql_query(“SELECT id, competitionname, competitiondate FROM competition where competitionname = ‘$competition’ order by competitiondate”);
echo “<table border=‘0’ align=‘center’>”;
echo “<tr><th>id</th> <th>name</th> <th>date</th> <th>start</th></tr>”;
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo “<tr><font size=‘2’><td align=‘justify’>”;
echo $row[‘id’];
echo “</td><td align=‘justify’>”;
echo $row[‘competitionname’];
echo “</td><td align=‘center’>”;
echo $row[‘competitiondate’];
echo “</td><td align=‘center’>”;
echo $row[‘starttime’];
echo “</td><td align=‘center’>”;
echo "</td></tr>";
}
echo “</table>”;
?>
Basically tester.php acts as required and displays a dropdown list with the competitions listed, but when I select one and submit it, all that is displayed in index3.php is the table with no results.
It seems that the selected value is not getting passed to the index.php file!
Am I making a mistake with the <select name=‘competitionname’>