I need someone else to look at this because I'm sure it's incredibly simple...
I'm sure this is a simple markup problem that I'm just not seeing, but $db->Paginate will only display where it's commented out. It won't display where it is currently placed (EOF) and I can't figure out why.
Working example: http://vintageamore.com/1/testdb.php
I'm sure this is a simple markup problem that I'm just not seeing, but $db->Paginate will only display where it's commented out. It won't display where it is currently placed (EOF) and I can't figure out why.
include 'MySQL.php';
$table = "dresses";
$db = &new MySQL();
$db->SetConnectionVars("host", "user", "pass", "dbname");
$db->DBConnect();
$db->SetPageResults(5);
$db->SetTable($table);
$db->SetQuery("SELECT * FROM ".$db->GetTable()."");
$db->SetMaxRows($db->GetNumRows());
//echo $db->Paginate();
if(isset($_GET['pg'])){
if($_GET['pg'] == "all"){
$db->SetStart(0);
$db->SetStop($db->GetMaxRows());
} else {
$db->SetStart($_GET['pg']);
$db->SetStop($db->GetPageResults());
}
} else {
$db->SetStart(0);
$db->SetStop($db->GetPageResults());
}
$db->SetQuery("SELECT * FROM ".$db->GetTable()." ORDER BY id DESC LIMIT ".$db->GetStart().", ".$db->GetStop()."");
echo "<table width=800 border=1 cellpadding=6>";
echo "<tr>";
for($i = 0;$i < $db->GetNumFields(); $i++){
echo "<td>";
echo $db->GetFieldName($i);
echo "</td>";
}
echo "</tr>";
while ($row = $db->FetchArray()) {
echo "<tr>";
for($i = 0;$i < $db->GetNumFields(); $i++){
$isOdd = ($i % 2);
if($isOdd == 1) $style = "#e9e9e9";
else $style = "#e1e1e1";
echo "<td bgcolor=\"".$style."\">";
echo $row[$db->GetFieldName($i)];
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
echo $db->Paginate();
Paginate Function:
function Paginate(){
$pages = ceil($this->GetMaxRows() / $this->GetPageResults());
$return = "<font class=\"paginate\">".$this->GetMaxRows()." total results. Pages: </font>";
for($i = 0;$i < $pages; $i++){
$return = $return."<a href=\"".$_SERVER['PHP_SELF']."?pg=".($i * $this->GetPageResults())."\" class=\"\">".($i + 1)."</a> ";
}
$return = $return."<a href=\"".$_SERVER['PHP_SELF']."?pg=all\">View All</a>";
return $return;
}
Working example: http://vintageamore.com/1/testdb.php
