I choose something from selectbox and click on the button and i get list of the data from database but, whatever i choose from selectbox doesn't remain what i have chosen. It sets itself to first value. How can i do "selected" ?
<?php
$mysqli = new mysqli("localhost","root","","inantest");
if (mysqli_connect_errno()) {
printf ("Connection failed : %s\n", mysqli_connect_error());
exit();
}
if ("Ara" == $_POST["iller"]) {
//$select = "selected=\"Selected\"";
$aranacakIl=$_POST["selectIl"];
$sql = "SELECT * FROM plaka WHERE ilName= '$aranacakIl' ";
$calistir = mysqli_query($mysqli, $sql);
if ($calistir) {
while ($newArray = mysqli_fetch_array ($calistir, MYSQLI_ASSOC)) {
$plaka = $newArray['ilPlaka'];
}
}
$sql = "SELECT * FROM ilce WHERE ilPlaka= '$plaka' ";
$calistir = mysqli_query($mysqli, $sql);
if ($calistir) {
while ($newArray = mysqli_fetch_array ($calistir, MYSQLI_ASSOC)) {
$ilce = $newArray['ililce'];
print "$ilce<br>";
}
}
}
?>
<form method="post" action="">
<select name="selectIl">
<?php
$sql = "SELECT * FROM il";
$calistir = mysqli_query($mysqli, $sql);
if ($calistir) {
while ($newArray = mysqli_fetch_array ($calistir, MYSQLI_ASSOC)) {
$il = $newArray['ilName'];
printf("<option value=\"$il\">$il</option>");
}
//mysqli_free_result($calistir);
//mysqli_close($mysqli);
}
?>
</select>
<input type="submit" name="iller" value="Ara" />
</form>