[英]PDO fetch table not working
I'm try to use the following script to fetch user data from a table 我尝试使用以下脚本从表中获取用户数据
//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>";
I don't receive any error messages, but neither do I recieved the desire output. 我没有收到任何错误消息,但是我也没有收到期望的输出。 All I get is the table headings, what am doing wrong? 我所得到的只是表格标题,这是怎么了?
Well, you don't execute your query. 好吧,您不执行查询。
$stmt->execute();
After a query is prepared, and all parameters/values are bound, you need to execute your query. 准备查询并绑定所有参数/值后,您需要执行查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.