Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //Connection vars set correctly above this line
  2. $link = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect to database");
  3. mysql_select_db("$dbName") or die("Unable to select database $dbName");
  4.  
  5. $sqlquery = "select text1, text2 ".
  6.             "from myTable ".
  7.             "where selectValue='".mysql_real_escape_string($_POST['selectValue'])."'";
  8.  
  9. $results = mysql_query($sqlquery) or die('Query failed: ' . mysql_error());;
  10.  
  11. if ($row = mysql_fetch_assoc($results)){
  12.   //put results in value of inputs
  13.   echo "<input type='text' id='text1' name='text1' value='".$row['text1']."' />";
  14.   echo "<input type='text' id='text2' name='text2' value='".$row['text1']."' />";
  15. } else {
  16.   //since there was no result, show empty inputs
  17.   echo "<input type='text' id='text1' name='text1' />";
  18.   echo "<input type='text' id='text2' name='text2' />";
  19. }
  20.  
  21. mysql_close($link);
  22.