Trying to grasp this so I can add all geography_map keys in one form. Just curious if I am going towards teh right path?
if(isset($_POST['submit'])){// handle the form
// Connect to the database.
require_once ('../incl/mysql_connect.php');
// Query the database.
$zone_id = mysql_real_escape_string($_POST['zone_id']);
$legend_key = mysql_real_escape_string($_POST['legend_key']);
$legend = mysql_real_escape_string($_POST['legend']);
$query = "INSERT INTO geography_map
(legend_id, zone_id, legend_key, legend)
VALUES
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend'),
('$legend_id', '$level', '$legend_key', '$legend')
";
$result = @mysql_query ($query); // Run the query.
if ($result) { // If it ran OK.
// Send an email, if desired.
echo '<table width=95% align=center class=tableOutline>
<tr><td><p>Thank you for adding this zone!</p><p><a href=/forms/add_zone.php target=_self>Back</a></p></td></tr></table>';
exit();
} else { // If it did not run OK.
// Send a message to the error log, if desired.
echo '<table width=95% align=center class=tableOutline>
<tr><td><p>Your information could not be registered due to a system error. We apologize for any inconvenience.</p></td></tr></table>';
}
mysql_close(); // Close the database connection.
}
And if this is along the right path in my form will I repeat this 10 times?
<tr><td valign="top">Zone: <select class="SelectInput" name="zone_id">
<option value=""></option>
require_once ('../incl/mysql_connect.php');
$q = "select zone_id, zone from geography_zone order by zone";
$result = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<option value=\"$zone_id\">$zone</option>";
}
</select></td>
<td valign="top">Legend Key: <input class="TextInput" type="text" name="legend_key" size="5" maxlength="10" value="" /></td>
<td valign="top">Legend: <input class="TextInput" type="text" name="legend" size="50" maxlength="255" value="" /></td>
</tr>