//Connection vars set correctly above this line
$link = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect to database");
mysql_select_db("$dbName") or die("Unable to select database $dbName");
$sqlquery = "select text1, text2 ".
"from myTable ".
"where selectValue='".mysql_real_escape_string($_POST['selectValue'])."'";
$results = mysql_query($sqlquery) or die('Query failed: ' . mysql_error());;
if ($row = mysql_fetch_assoc($results)){
//put results in value of inputs
echo "<input type='text' id='text1' name='text1' value='".$row['text1']."' />";
echo "<input type='text' id='text2' name='text2' value='".$row['text1']."' />";
} else {
//since there was no result, show empty inputs
echo "<input type='text' id='text1' name='text1' />";
echo "<input type='text' id='text2' name='text2' />";
}
mysql_close($link);