Basically, I have this code and everything works in it EXCEPT I want the dropdown box to fill with options from another database table.
When I put new info into the other database table, I want it to be available for me to select it as an option in the dropdown box. I marked right above the line and I want to autofill with options from the other database table.
Thanks! It's near the bottom I just wanted you to have the WHOLE function.
<?php
function editarea($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; }
if ($latitude == "") { $errors++; $errorlist .= "Latitude is required.<br />"; }
if (!is_numeric($latitude)) { $errors++; $errorlist .= "Latitude must be a number.<br />"; }
if ($longitude == "") { $errors++; $errorlist .= "Longitude is required.<br />"; }
if (!is_numeric($longitude)) { $errors++; $errorlist .= "Longitude must be a number.<br />"; }
if ($elevation == "") { $errors++; $errorlist .= "Elevation is required.<br />"; }
if (!is_numeric($elevation)) { $errors++; $errorlist .= "Elevation must be a number.<br />"; }
if ($creatureid == "") { $errors++; $errorlist .= "creatureid is required.<br />"; }
if (!is_numeric($creatureid)) { $errors++; $errorlist .= "creatureid must be a number.<br />"; }
if ($exploretext == "") { $errors++; $errorlist .= "Explore Text is required.<br />"; }
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',latitude='$latitude',longitude='$longitude',elevation='$elevation',creatureid='$creatureid',n='$n',s='$s',e='$e',w='$w',nw='$nw',ne='$ne',se='$se',sw='$sw',u='$u',d='$d' ,exploretext='$exploretext' WHERE id='$id' LIMIT 1", "area");
admindisplay("Area updated.","Edit Area");
} else {
admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Edit Area");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "area");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Edit Area</u></b><br /><br />
<form action="admin.php?do=editarea:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Latitude:</td><td><input type="text" name="latitude" size="5" maxlength="10" value="{{latitude}}" /><br /><span class="small">Positive or negative integer.</span></td></tr>
<tr><td width="20%">Longitude:</td><td><input type="text" name="longitude" size="5" maxlength="10" value="{{longitude}}" /><br /><span class="small">Positive or negative integer.</span></td></tr>
<tr><td width="20%">Elevation:</td><td><input type="text" name="elevation" size="5" maxlength="10" value="{{elevation}}" /><br /><span class="small">Positive or negative integer.</span></td></tr>
<tr><td width="20%">Creature ID:</td><td><input type="text" name="creatureid" size="5" maxlength="10" value="{{creatureid}}" /> ID<br /><span class="small">Positive integer.</span></td></tr>
<tr><td width="20%">Exploring Text:</td><td><input type="text" name="exploretext" size="50" maxlength="255" value="{{exploretext}}" /><br /><span class="small">Exploring Text to be seen.</span></td></tr>
<tr><td width="20%">Value connects NORTH to:</td><td><input type="text" name="n" size="5" maxlength="10" value="{{n}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects EAST to:</td><td><input type="text" name="e" size="5" maxlength="10" value="{{e}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects SOUTH to:</td><td><input type="text" name="s" size="5" maxlength="10" value="{{s}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects WEST to:</td><td><input type="text" name="w" size="5" maxlength="10" value="{{w}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects NORTHWEST to:</td><td><input type="text" name="nw" size="5" maxlength="10" value="{{nw}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects NORTHEAST to:</td><td><input type="text" name="ne" size="5" maxlength="10" value="{{ne}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects SOUTHEAST to:</td><td><input type="text" name="se" size="5" maxlength="10" value="{{se}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects SOUTHWEST to:</td><td><input type="text" name="sw" size="5" maxlength="10" value="{{sw}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects UP to:</td><td><input type="text" name="u" size="5" maxlength="10" value="{{u}}" /><br /><span class="small">Area ID.</span></td></tr>
<tr><td width="20%">Value connects DOWN to:</td><td><input type="text" name="d" size="5" maxlength="10" value="{{d}}" /><br /><span class="small">Area ID.</span></td></tr>
<------------------THIS one below is the one i want to autopull for dropbox-------------------->
<tr><td width="20%">North Connection:</td><td><select name="area"><option value="0" {{n0select}}>None</option><option value="{{id}}">$row[name] Lat:$row[latitude] Long:$row[longitude] Elev:$row[elevation]</option></select><br /><span class="small">test</span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" />
</form>
END;
if ($row["n"] == 0) { $row["n1select"] = "selected=\"selected\" "; } else { $row["n1select"] = ""; }
if ($row["n"] != 1) { $row["n2select"] = "selected=\"$row[n]\" "; } else { $row["n2select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Edit Area");
}