Pagination
Posted on
16th Feb 2014 07:03 pm by
admin
Okay here is the page in question: http://blenderteachings.000a.biz/tutorials.hamishhill.php
I have the records in a database(tutorial name, username description etc). I am pulling these and displaying them but i need them to be set out like this http://blenderteachings.000a.biz/index.php
But my code doesnt do it like that. Any ideas?
Heres the code:
Code: <?php
ob_start();
include('header.php');
include('db.php');
$db=mysql_connect($db_host,$db_user,$db_pass)
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db($db_name,$db);
if (!(isset($pagenum)))
{
$pagenum = 1;
}
$data = mysql_query("SELECT * FROM tutorials") or die(mysql_error());
$rows = mysql_num_rows($data);
$page_rows = 3;
$last = ceil($rows/$page_rows);
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
$sql = "SELECT username, fullname, description, link
FROM tutorials
WHERE username='hamsterhill' $max";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
?>
<div id="page">
<div id="content">
<div class="post">
<p class="meta"><?php echo $row["fullname"] . ' | ' .$row["username"]; ?>
<img src="images/img08.png" alt="bullet"></p>
<div class="entry">
<?php echo $row['description']; echo '<br />'; } ?>
</div>
</div>
<?php
echo " Page $pagenum of $last <p>";
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}
//This does the same as above, only checking if we are on the last page, and then
generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}
?>
</div>
<?php include('footer.php');
ob_flush();
mysql_close($db);
?>
No comments posted yet
Your Answer:
Login to answer
300 51
Other forums
Create comparison matrix?
I want to create a comparison script for forum software and was wondering is there any tutorial or b
SuperCali PHP Event Calendar
does anyone have any experience with the SuperCali PHP Event Calendar? I could use some assistance
Server side $_SESSION
how does one keep the session completely server side. no cookies to the browser at all. i need this
Edit MySQL Row Using PHP and HTML Form
Hello,
Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.
controlling/creating accounts with privileges
hi all,
i'm trying to figure out how i can create/control account with privileges, for instance a
Mysql query, two times?
Hello to all,
I'm new to php coding and i like it alot. I need help with some noob stuff.
extending tidy
I have problem with type-hinting and extending tidy. This code creates error:
Code: class cMyTidy
Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was
How to Detect it is public_html or httpdocs?
How to check whether it is cPanel or Plesk?
If it found public_html perform <?php incl
How to read posted binary data from a mobile device and post it to a web server?
Here is the senario...
I have a mobile device (MD) that posts binary data to a Web Server (WS