<!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');
// Opens a connection to a MySQL server.
$connection = mysql_connect ($server, $username, $password);
if (!$connection)
{
die('Not connected : ' . mysql_error());
}
// Sets the active MySQL database.
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected)
{
die ('Can\'t use db : ' . mysql_error());
}
$vartocheckfor = ''; //set this via querystring or whatever.
$db = 'consolep_KmlWork'; //use this database in queries
$table = 'State'; //use this table in queries
$where = ' WHERE 1'; //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 CTECH_Kml WHERE 1');
$q = mysql_query("SELECT * FROM $db.$table $where");
if (!$q)
{
die('Invalid query: ' . mysql_error());
}
while($qd = mysql_fetch_assoc($q))
{
?>
<option value="<?=$qd['id']?>"<?if($vartocheckfor == $qd[State_Name]){?>
selected<?}?>><?=$qd[State_Name]?></option>
<?
}
?>
</select>
</body>
</html>
Bookmarks