<form action="1.php" method="GET" >
<select name="getir" class="form-select" aria-label="Default select example">
<option value="1">deneme1</option>
<option value="2">deneme2</option>
<option value="3">deneme3</option>
</select><br>
<button class="btn btn-primary btn-lg btn-block btn-success" type="submit">Test Et</button>
</form></center>
<?php
if ($_GET) {
$gelen=$_GET['getir'];
if ($gelen==1) {
include("2.php");
} elseif ($gelen==2) {
include("3.php");
} elseif ($gelen==3) {
include("4.php");
}
}
?> option ile seçim yaptıktan sonra
6
●138
- 03-02-2024, 18:17:24merhaba option ile seçim yaptıktan sonra option tekrar başa dönüyor yani deneme 3 ü seçtiğim zaman form geliyor ama option deneme 1 oluyor acaba seçileni option value de nasıl tutabilirim.
- 03-02-2024, 18:40:06bir sorgu yap mesela
$query = $db->query("SELECT * FROM tabloadı ORDER BY tabloid DESC", PDO::FETCH_ASSOC);
foreach( $query as $row ){
echo '<option value="'.$row['id'].' selected">'.$row['secilenisim'].'</option>';
gibi gibi mesela - 03-02-2024, 19:28:35ozaman if else gibi kullanıp seçili olana selected vermen gerekiyoralpskrtl adlı üyeden alıntı: mesajı görüntüle
- 03-02-2024, 19:58:18php tarafında şöyle bir şey yapabilirsin
<form action="1.php" method="GET" > <select id="myIndex" name="getir" class="form-select" aria-label="Default select example"> <option value="1" <?php echo isset($_GET['getir']) && $_GET['getir'] == 1 ? ' selected ' : '';?>>deneme1</option> <option value="2" <?php echo isset($_GET['getir']) && $_GET['getir'] == 2 ? ' selected ' : '';?>>deneme2</option> <option value="3" <?php echo isset($_GET['getir']) && $_GET['getir'] == 3 ? ' selected ' : '';?>>deneme3</option> </select><br> <button class="btn btn-primary btn-lg btn-block btn-success" type="submit" >Test Et</button> </form> - 03-02-2024, 21:54:38