I wanna ask why I am getting just last row from DB, while I'm using fetchAll(); function? As a control for myself, I have added to see what I'll get.... The result is same... No metter what I select from tag, I'm getting only last row...
The code is next:
<form method="post" action="index.php">
<select name="namrli" onChange="location.reload()"><option value="0">Test?</option>
<?php
$query = $db->prepare("SELECT * FROM Server ORDER BY id");
$query->execute(array(':id' => $_POST['id']));
$result = $query->fetchAll();
foreach ($result as $row) {
$srvid = $row['id'];
$srvname = $row['Naziv'];
$srvslot = $row['Slotovi'];
$srvprice = $row['Cena'];
?>
<option value = "<?php $srvid;?>" selected="selected" name="ServerID"><?php echo $srvname; echo " - "; echo $srvslot; echo " - "; echo $srvprice;?></option>
<?php
}
?>
<input type="text" value="<?php echo $srvid; ?>" name="ServerID" />
</select>
<input type="hidden" value="<?php echo $uid; ?>" name="KorisnikID" />
<input type="submit" name="poruci" value="poruči" id="" />
</form>
I am stucked here....