I wouldn't put this on a live site...
PHP Code:
<form method="GET" name="SelectClient" action="client-history.php">
<label>Client Name:</label>
<select name="client_id" onChange="document.SelectClient.submit()">
<?php
if (isset($_GET['client_id']) && $_GET['client_id'] != "0" && $_GET['client_id'] != "") {
$ID_IS = $_GET['client_id'];
//prevent sql injection only allow numbers
settype($ID_IS, "integer")
$sql2 = "SELECT lastname, firstname FROM client where client_id = $ID_IS";
$result2 = mysql_query($sql2,$connection) or die("Couldn't execute $sql2 query.");
// Not familiar with mysql this might not be right
$row2 = mysql_fetch_row($result2)
$user_is = $row2[0];
$user_is =. $row2[1];
?>
<option value="<?php echo $ID_IS;?>" default><?php echo $user_is;?></option>
<?php
} else {
?>
<option value="0">Select an existing client...</option>
<?php }
$sql = "SELECT client_id, lastname, firstname FROM client ORDER BY lastname, firstname ASC ";
$result = mysql_query($sql,$connection) or die("Couldn't execute $sql query.");
while($row = mysql_fetch_row($result)){ ?>
<option value="<?php echo $row[0];?>"><?php echo $row[1]; echo ', '; echo $row[2];?></option>
<?php } ?>
</select>
</form>
Bookmarks