hello I'm wiritng a simple dynamic website in which the content of a div.container is loaded dynamically by jquery and since I also needed to update the url without reloading the page I use this script:
function ChangeUrl(page, url) {
if (typeof (history.pushState) != "undefined") {
var obj = { Page: page, Url: url };
history.pushState(obj, obj.Page, obj.Url);
}
}
$('ul.menu li a').on('click', function(){
var page = $(this).attr('href');
var pageUrl = page.split("/");
pageUrl = pageUrl[1];
$('.container').load(page + '.php', function(){
//fadeout old content
//fadein new content
});
ChangeUrl('Page1', '?page=' + page);
return false;
})
this script also allows me to reload (cmd+r // ctrl+r) the page with the exact div content. Now the problem is that I wrote a specific page in which inside the div.content I display an sql table:
<div class="section-inner main-content page">
<?php
$pdo = new PDO('mysql:host=localhost;port=8889;dbname=Table','user','pass');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$smtm = $pdo->query("SELECT item1, item2, item3,item4 FROM Table");
echo '<table border="1">'."\n";
while ($row = $smtm->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>";
echo($row['item1']);
echo("</td><td>");
echo($row['item2']);
echo("</td><td>");
echo($row['item3']);
echo("</td><td>");
echo($row['item4']);
echo("</td></tr>\n");
}
echo "</table>\n";
?>
</div>
but when I reload this page from the browser the table is not displayed. any suggestion?