blackbad88
01-18-2008, 12:13 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<select name="mydropdown">
<?
require('phpsqlajax_dbinfo.php');
$vartocheckfor = ''; //set this via querystring or whatever.
$db = 'consolep_KmlWork'; //use this database in queries
$table = 'State'; //use this table in queries
$where = ' WHERE'; //use this var for extra settings
if($where == ' WHERE'){unset($where);} //just in case you don't use the where var.
$q = mysql_query("SELECT * FROM $db.$table $where");
while($qd = mysql_fetch_assoc($q))
{
?>
<option value="<?=$qd[Field1]?>"<?if($vartocheckfor == $qd[Field1]){?>
selected<?}?>><?=$qd[Field2]?></option>
<?
}
?>
</select>
</body>
</html>
What's wrong with this code. I have 50 states in a database and i want my php code to access them and put them in a drop down box.:confused:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<select name="mydropdown">
<?
require('phpsqlajax_dbinfo.php');
$vartocheckfor = ''; //set this via querystring or whatever.
$db = 'consolep_KmlWork'; //use this database in queries
$table = 'State'; //use this table in queries
$where = ' WHERE'; //use this var for extra settings
if($where == ' WHERE'){unset($where);} //just in case you don't use the where var.
$q = mysql_query("SELECT * FROM $db.$table $where");
while($qd = mysql_fetch_assoc($q))
{
?>
<option value="<?=$qd[Field1]?>"<?if($vartocheckfor == $qd[Field1]){?>
selected<?}?>><?=$qd[Field2]?></option>
<?
}
?>
</select>
</body>
</html>
What's wrong with this code. I have 50 states in a database and i want my php code to access them and put them in a drop down box.:confused: