0

http://www.w3schools.com/php/php_ajax_database.asp

I have been looking at this sample for a week now trying to make adjustments to change the output for a GET method to fill the forms with data from the sql drop list. I have been over snippet after snippet trying to work this out.

I have the drop list worked out which lists all the product codes in the sql, but for the life of me i have no idea how to activate the $_GET to pull to the data to the input form.

Am i going about this the right way by going through ajax or should i start looking at ASP? I just need to be pointed in the right direction.

// Option 1
$sql="SELECT * FROM `cctv` ORDER BY `cctv`.`SAPCode` ASC ";
$q=mysql_query($sql);
echo "<select name=\"q_option1\">"; 
echo "<option size =30 ></option>";
while($row = mysql_fetch_array($q)) 
{        
echo "<option value='".$row['SAPCode']."'>".$row['SAPCode']."</option>"; 
}
echo "</select>";
?>

<form id="form1" name="form1" method="post" action="">
  <label for="price">price</label>
  <input type="text" name="price" id="price" />
</form>
Glenn Zealous
  • 72
  • 1
  • 7
  • Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Apr 12 '16 at 12:49
  • For GET you either have to have a form with no method (or `method="get"`) or a URL with a query string. You have no AJAX request in the code you're showing us. – Jay Blanchard Apr 12 '16 at 12:51
  • I got no ajax code as i got a dozen samples sitting in front of me trying to work out how to manipulate it to my needs but i have not found a way so far, the only thing that has worked is the sql drop down. I am reviewing the above links you have mentioned and i hope it will give me some direction to working out this problem. Thanks for the reply – Glenn Zealous Apr 12 '16 at 13:02

0 Answers0