PDO返回最后一行

时间:2017-03-14 15:42:05

标签: php mysql pdo

我想问为什么我从DB获取最后一行,而我正在使用fetchAll();功能?作为对自己的控制,我已经添加了,看看我会得到什么....结果是一样的...没有我从标签中选择的东西,我只得到最后一排......

代码是下一个:

 <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>

我被困在这里......

0 个答案:

没有答案