I finally got this working, and all it does is populate a drop-down, but I had a few questions.
1. Where should I put my validation?
2. Should I put the form action script on this page?
3. I know there's more than one way to skin a cat(not that I would ever do that), are there some built-in functions of php that would have made this easier?
4. Separating code and markup does make it easier to read in Dreamweaver and PhpED, but is that really the way the pros do it.
5. If I wanted this to work in php5 is this the only alteration I would need?PHP Code:<?php
//deleted connection data
$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die('Error connecting to MySQL.');
mysql_select_db($dbname)
or die('Error selecting database.');
//following are all fields remember to change to *
$query='SELECT MenuCategoryID, MenuCategoryName FROM universitymenucategory';
$result=mysql_query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add menu item</title>
</head>
<body>
<form action="../ManagerSection/PHP_Scripts/AddMenuItem.php"
method="post">
<fieldset>
<legend>Add menu item</legend>
<ol>
<li><label for="form-ItemName">Item name:</label> <input type="text"
name="name" id="form-name"></li>
<li><label for="form-ItemPrice">Price: $</label><input type="text" name="price" id="form-price"></li>
<li><label for="form-ItemDescription">Description:</label><textarea name="Description" rows="4" cols="60" maxlength="300">(300 characters max)</textarea></li>
<li><label for="form-Category">What category does this menu item belong?<label><br />
<select name="MenuCategory" id="form-Category">
<?php
while ($row = mysql_fetch_array($result)) {
?>
<option value="
<?php
echo $row['MenuCategoryID']
?>
">
<?php
echo $row['MenuCategoryName'];
?>
</option>
<?php
}
?>
</select></label></li>
</ol>
<input type="submit" value="Add item">
</fieldset>
</form>
</body>
</html>
toPHP Code:$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die('Error connecting to MySQL.');
mysql_select_db($dbname)
or die('Error selecting database.');
Many thanks,PHP Code:$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname)
or die('Error connecting to MySQL.');
Joe



Reply With Quote



Bookmarks