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_q uery($sql);
$options="";
while ($row=mysql_fet ch_array($resul t)) {
$id=$row["cat"];
$cat=$row["category"];
$options.="<OPT ION 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="multip art/form-data">
<p>Title
<input type="text" name="Title">
</p>
<p>Spot #
<input type="text" name="Spot_Numb er">
</p>
<p>Series
<select name="Series" id="Series">
<option value="test">te st</option>
</select>
<a href="series_ed it.php">Manage Series</a> </p>
<p>Date
<input type="text" name="Creation_ Date">
</p>
<p>Category #1
<select name="Category_ One" id="Category_On e">
<option value="0"><? echo $options ?> </option>
</select>
<a href="category_ edit.php">Manag e 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_conn ect ("localhost" , "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("snmwebde_ryno db");
$Title=$_POST{' Title'};
$Spot_Number=$_ POST{'Spot_Numb er'};
$Series=$_POST{ 'Series'};
$Creation_Date= $_POST{'Creatio n_Date'};
$Category_One=$ _POST{'Category _One'};
?>
<?PHP
$query = "insert into spots values
('$Title','$Spo t_Number','$Ser ies','$Creation _Date','$Catego ry_One')";
$result = mysql_query($qu ery);
?>
Entry added!!<br>
To view database click <a href="viewdb.ph p">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
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_q uery($sql);
$options="";
while ($row=mysql_fet ch_array($resul t)) {
$id=$row["cat"];
$cat=$row["category"];
$options.="<OPT ION 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="multip art/form-data">
<p>Title
<input type="text" name="Title">
</p>
<p>Spot #
<input type="text" name="Spot_Numb er">
</p>
<p>Series
<select name="Series" id="Series">
<option value="test">te st</option>
</select>
<a href="series_ed it.php">Manage Series</a> </p>
<p>Date
<input type="text" name="Creation_ Date">
</p>
<p>Category #1
<select name="Category_ One" id="Category_On e">
<option value="0"><? echo $options ?> </option>
</select>
<a href="category_ edit.php">Manag e 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_conn ect ("localhost" , "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("snmwebde_ryno db");
$Title=$_POST{' Title'};
$Spot_Number=$_ POST{'Spot_Numb er'};
$Series=$_POST{ 'Series'};
$Creation_Date= $_POST{'Creatio n_Date'};
$Category_One=$ _POST{'Category _One'};
?>
<?PHP
$query = "insert into spots values
('$Title','$Spo t_Number','$Ser ies','$Creation _Date','$Catego ry_One')";
$result = mysql_query($qu ery);
?>
Entry added!!<br>
To view database click <a href="viewdb.ph p">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
Comment