Database, php pdo and html

梦想的初衷 提交于 2020-01-16 10:13:07

问题


I have been going over the same scenario several times but It just wont work for me regardless of what I do. What I am trying to do is update my website content straight from my database. I have tables that correspond to my tables in my webpage and I want to simply outut the results.

This is how It looks right nw

<?php
$file = dirname(__FILE__) . "/db.sqlite";
$db = new PDO("sqlite:$file");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
?>

<div class="featured">
<h3>Featured</h3>
<?php
if(!$res)
echo"No Content Available Yet..";
else  
echo "<table>";
foreach($res AS $val) {
 echo "<tr>";
 foreach($val AS $val1) {
echo "<td>$val1</td>";
 }
echo "</tr>";
}
echo "</table>";
$db = null;
?>
</div>

**This works fine for one piece of content but when I want to use the same code for my next column, it stops working.

*So in other words when I try to retreive data from another table, I dont know how to do it. *

来源:https://stackoverflow.com/questions/14480555/database-php-pdo-and-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!