簡體   English   中英

PDO提取表不起作用

[英]PDO fetch table not working

我嘗試使用以下腳本從表中獲取用戶數據

//if session detected connect to database using pdo
$db = getConnection();

$user = getUser();

//qry the databse
$stmt = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID = :email");
$stmt->bindParam(":email", $user);


echo "<br></br>
    <table border='2' align='left' width='700'>
    <th align='left'>HolidayID</th>
    <th align='left'>SubscriberID</th>
    <th align='left'>Link</th>
    <th align='left'>Published</th>
    <th align='left'>Title</th>
    <th align='left'>Description</th>
    <th align='left'>Saved</th>
    <br></br>
    <br></br>";

while($obj = $stmt->fetchObject())

{
    echo "<tr><td>".$obj->holidayID."</td><td>".$obj->subcriberID."</td><td>".$obj->link."</td><td>".
    $obj->pubDate."</td><td>".$obj->title ."<td>".$obj->dateSaved."</td><br/>\n"."</td></tr>";
}

echo "</table>
    <br></br>
    <br></br>"; 

我沒有收到任何錯誤消息,但是我也沒有收到期望的輸出。 我所得到的只是表格標題,這是怎么了?

好吧,您不執行查詢。

$stmt->execute();

准備查詢並綁定所有參數/值后,您需要執行查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM