HI first timer here so please forgive me if this is in the wrong section.
Anyway, here goes.
I have 2 tables
Table 1
Levels
LevelID
LevelName
Table 2
Members
MemberID
FirstName
LastName
Birthdate
LevelID
I have a form that has the LevelID populated from table 1 with a query. When I enter all my data and hit submit the data gets written to the members table. However, the LevelID is written as 0 for each and everyone record that I have entered. So the question is what am I missing?
As mentioned I am very new at this so any help would be greatly appreciated. Please see below for my code.
Thanks in advance
<?php
require_once 'dblogin1.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());
$sql = "SELECT\n"
. "levels.LevelID,\n"
. "levels.LevelName\n"
. "FROM\n"
. "levels\n";
$result = mysql_query($sql) or die(mysql_error());
$options="";
while($row = mysql_fetch_array($result)){
$LevelId=$row["LevelID"];
$LevelName=$row["LevelName"];
$options.="<OPTION VALUE=\"$LevelID\">".$LevelName.'</option>';
}
?>
<style type="text/css">
<!--
body p {
color: #F00;
}
-->
</style>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="1" >
<tr>
<td>
<form name="form1" method="post" action="insert_ac.php">
<table width="100%" border="1" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><div align="center">
<p><strong>Myers Player Registration Form</strong></p>
</div></td>
</tr>
<tr>
<td>First Name</td>
<td><div align="center">:</div></td>
<td><input name="firstname" type="text" id="firstname"></td>
</tr>
<tr>
<td>Last Name</td>
<td><div align="center">:</div></td>
<td><input name="lastname" type="text" id="lastname"></td>
</tr>
<tr>
<td>Birthdate (yyyy-mm-dd)</td>
<td><div align="center">:</div></td>
<td><input name="birthdate" type="text" id="birthdate">
</td>
</tr>
<tr>
<td>Level</td>
<td><div align="center">:</div></td>
<td><select name="LevelID">
<OPTION VALUE="0">Choose
<?php echo $options?>
</select></td>
</tr>
</form>
</td>
</tr>
</table>