need some input
i know how to populate a php dropdown list from MSSQLServer Datebase and save the selected value in the datebase, but i want to add new dynamical entrys in the dropdown menu and save them into the database. Here is the code:
$connection = new PDO("sqlsrv:Server=$hostname;Database=Master",
$username, $password);
if($connection){echo '';}else{echo 'Verbindung fehlgeschlagen<br />';die(print_r(sqlsrv_errors(),TRUE));}
$sta = $connection->query("SELECT StatusID, Status FROM Master.dbo.Status");
$sta->execute();
<select name="StatusID" size="1" required>
<option disabled selected value> </option>;
<?php
foreach($result as $m)
{
echo "<option value=\"" . $m['StatusID'] . "\">".$m['Status']. "</option>";
}
?>
$Status = $_POST['Status'];
$sth = $connection->prepare("INSERT INTO Master.dbo.AllgemeineAngaben (StatusID) VALUES ('$StatusID')");
$sth->execute();
some help?
from Adding dynamical options to PHP populated Dropdown from SQLServer Database
No comments:
Post a Comment