Flourish - database

Post Reply
MrCambron
Posts: 11
Joined: Tue Dec 19, 2017 5:34 pm

Flourish - database

Post by MrCambron » Wed Jul 11, 2018 8:48 pm

Flourish - database.

I don't remember what this code was for. It may have been for the framework code compendium. Looks like some kind of pageination script that I have made. It is my scripting with a bit out of date structures.

Code: Select all

<?php
/**
  Flourish:database
**/
__autoload('fDatabase');
$mysql_db = new fDatabase($my[0], $my[1], $my[2], $my[3], $my[4]);
$mysql_db->connect();

/**
  The $s will will keep track of pagination
**/
if (isset($_GET['s'])&&ctype_digit($_GET['s'])) {
  $s = $_GET['s'];
} else {
  $s = 0;
}

/**
  Les run the sql
**/
$result = $mysql_db->query('SELECT * FROM entries ORDER BY id DESC LIMIT '.$s.', 10');
$output = '';
foreach ($result as $row) {
  $output .= "<section>\n".
    "<h2>{$row['title']}</h2>\n".
    "<span class=\"k\">By: <a href=\"{$row['from_link']}\">{$row['from_name']}</a></span>\n".
    "<span class=\"k\">Date: {$row['date']}</span>\n".
    "<br />\n".
    "{$row['body']}\n".
    "  <br class=\"c\" />\n".
    "</section>\n";
  $lastrow = $row['id'];
}
if (isset($output))echo $output;
?>

/**
  Les paginate some links
**/
<section>
<?php
if (isset($s)) {
  if ($s > 0) {
    echo "<div style=\"float: left;\">\n";
    echo "<a href=\"{$_SERVER['PHP_SELF']}?s=".($s-10)."\">";
    echo "Newer entries";
    echo "</a>\n";
    echo "</div>\n";
  }
  if ($lastrow>1) {
    echo "<div style=\"float: right;\">\n";
    echo "<a href=\"{$_SERVER['PHP_SELF']}?s=".($s+10)."\">";
    echo "Older entries";
    echo "</a>\n";
    echo "</div>\n";
  }
  echo "<br style=\"clear: both;\" />\n";
}
?>
</section>

Post Reply