i have a select option in index.html , i want to get result from mySQL via php, but how to get the result from php ,and add results to html automatically
index.html:
<form action="get.php" method="post" >
<select>
<option class="rm" value="trap"><get results from php></option>
.............
</select>
</form>
If you could show me a working example which does that, or may be any similar idea, it would be good.
I don't really understand what you mean. But did you mean something like this:
<html>
<body>
<select>
<?php
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include "$root/config.php";
$something1 = "something1";
$something2 = "something2";
$stmt = $pdo->prepare('SELECT DISTINCT from_mysql FROM customers WHERE something1 = :something1 AND from_mysql != :something2 ORDER BY from_mysql');
$stmt->execute(array(':something1' => $something1, ':something2' => $something2));
$results = $stmt->fetchAll();
if (empty($results)) {
echo 'Error: Please contact technical support!';
} else {
foreach( $results as $row ) {
echo "<option>".$row['from_mysql']."</option>";
}
}
?>
</select>
</body>
</html>
P.S. You'll have to use index.php