php and forms

A

Anonymous

Guest
Code:
<?php

$forlease = mysql_query("SELECT ADDRESS, SUBURB FROM UNIVERSAL"); 

while ($lease = mysql_fetch_array($forlease)) { 
$address = $lease['ADDRESS']; 
$suburb = $lease['SUBURB']; 

$optionstring1 .= "<option>$address</option>";

}

echo $optionstring1;

?>
 
Hi.

I do this with a number of what I call "Dynamic" drop down menus. I'm sure there's a proper term for it but hey: it works...

Example:

Here's a form field I might use:

Code:
<select size="1" name="City">
			 <option selected>Please Select</option>
  		<?php include "INC/Options/City.php"; ?>
		</select>

City.php:

Code:
// Grab The Results:
   $Query01 = "SELECT City FROM options
   WHERE City != ''
   ORDER BY City";
   $Result01 = mysql_query($Query01) or die("<br><br>Error 01: " . mysql_error());

// Create Drop-down Menu List (Countries):			
			while ($listitem = mysql_fetch_object($Result01)) 
			{
			echo "\n<option value='" . $listitem->City . "'>" . $listitem->City . "</option>";
			}

I hoe that helps some...
 
Back
Top