Quote:
Originally Posted by Bertman105
Hey all,
Heres the situation:
I have a form page that needs to have multiple drop down menus that is pulling their options from a database. Right now I have one working out of 3. So that is one issue, now the issue that I am having with the one that is working, is that it is not writing anything to the database. No matter what you select, the database is empty. Any help would be sweet.
So here is the form page, with just a few text fields, and the one dynamic drop down that is working:
[PHP]<?PHP
//this code is bringing in the values for the dropdown.
$sql="SELECT * FROM category";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["cat"];
$cat=$row["category"];
$options.="<OPTION VALUE=\"$id\">".$cat.'</option>';
}
?>
<html>
<head>
<title>Manage Spots</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><form action="process.php" method="post" enctype="multipart/form-data">
<p>Title
<input type="text" name="Title">
</p>
<p>Spot #
<input type="text" name="Spot_Number">
</p>
<p>Series
<select name="Series" id="Series">
<option value="test">test</option>
</select>
<a href="series_edit.php">Manage Series</a> </p>
<p>Date
<input type="text" name="Creation_Date">
</p>
<p>Category #1
<select name="Category_One" id="Category_One">
<option value="0"><? echo $options ?> </option>
</select>
<a href="category_edit.php">Manage Categories</a>
</p>
<p> </p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>[/PHP]
Then I have it going to a page called process.php that just inserts everything into the database, here is the page if that helps:
[PHP]<?PHP
$dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("snmwebde_rynodb");
$Title=$_POST{'Title'};
$Spot_Number=$_POST{'Spot_Number'};
$Series=$_POST{'Series'};
$Creation_Date=$_POST{'Creation_Date'};
$Category_One=$_POST{'Category_One'};
?>
<?PHP
$query = "insert into spots values
('$Title','$Spot_Number','$Series','$Creation_Date ','$Category_One')";
$result = mysql_query($query);
?>
Entry added!!<br>
To view database click <a href="viewdb.php">here</a>.
</body>
</html>[/PHP]
Any help would be really great, seeing if i fix these 2 problems, I am done with this project. Thanks again
Have you investigated any errors coming out of the select, like this:
[php]$result=mysql_query($sql)
or die("Select query error: " . mysql_error());[/php]
At least you know then what the actual problem might be and where to look further.
Ronald :cool: