ksharpesays
13 Jun 2010, 01:09 PM
I am trying to make a database of college bars, organized by school. I created a form for bars to add themselves to the database that can be found at http://sofnthirsty.com/kevin/bar.php?act=add Ideally- for those of you who looked at the form - I would like to have the Nearby School/University drop down display a list of Schools in a given state. For example: When someone selects NJ in the State dropdown above- the Nearby School/University menu would show Rutgers, Stockton College, Kean, Farleigh ****inson, Seton Hall, Princeton, Montclair, Rowan, etc etc. so I need to change the code below accordingly. Any help would be appreciated, I hope I gave you guys enough information to be able to provide assistance.. Here is the code so far:
<tr>
<td class="fieldheading">State</td>
<td><select class="ddown" name="bstate" id="bstate" style="width:231px">
<?php
foreach( $states as $key=>$value)
{
?>
<option <?php if($value=="AL"){echo 'selected="selected"';} ?> value="<?php echo $value;?>"><?php echo $key;?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td class="fieldheading">NearBy School/University</td>
<td>
<?php
$qry_schools = "SELECT * FROM ".$tblprefix."schools";
$rs_schools = $db->Execute($qry_schools);
?>
<select class="ddown" name="bschool" id="bschool" style="width:231px">
<?php while(!$rs_schools->EOF){?>
<option value="<?php echo $rs_schools->fields['id'];?>">
<?php echo $rs_schools->fields['name'];?>
</option>
<?php $rs_schools->MoveNext();
}
?>
</select>
</td>
</tr>
<tr>
<td class="fieldheading">State</td>
<td><select class="ddown" name="bstate" id="bstate" style="width:231px">
<?php
foreach( $states as $key=>$value)
{
?>
<option <?php if($value=="AL"){echo 'selected="selected"';} ?> value="<?php echo $value;?>"><?php echo $key;?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td class="fieldheading">NearBy School/University</td>
<td>
<?php
$qry_schools = "SELECT * FROM ".$tblprefix."schools";
$rs_schools = $db->Execute($qry_schools);
?>
<select class="ddown" name="bschool" id="bschool" style="width:231px">
<?php while(!$rs_schools->EOF){?>
<option value="<?php echo $rs_schools->fields['id'];?>">
<?php echo $rs_schools->fields['name'];?>
</option>
<?php $rs_schools->MoveNext();
}
?>
</select>
</td>
</tr>