Paging

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Yanayaya
Forum Commoner
Posts: 42
Joined: Tue Dec 02, 2008 7:49 am

Paging

Post by Yanayaya »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


ello guys,

I wrote this simple php page that takes the data entries from a mysql database and then displays them as links in a table. These links can then be clicked on to show more specific information about each job. I want to expand my page by allowing paging through the records. Does anyone know the best way to apply paging to my code?

Help is, as ever, appreciated.

Code: Select all

<?php
include 'configuration.php';
include 'opendatabase.php';
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="vacancy_style.css" rel="stylesheet" type="text/css">
 
</head>
<body>
 
<?php
//Run a query to select the data from the db, then organise it by id
$query = "SELECT id, jobtitle, jobtype, area, salary, qualifications, skills, jobdescription FROM jobpost ORDER BY id";
$result = mysql_query($query) or die('Error : ' . mysql_error());
?>
<p>&nbsp;</p>
<table width="668" border="0" cellpadding="5" cellspacing="5" id="JobBase">
  <tr>
    <td width="547" valign="top"><table width="490" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#fafafa" class="tblb" id="Jobs">
      <tr align="center" bgcolor="#dbdbdb">
        <td width="145"><h2 align="left">Job Title</h2></td>
        <td width="92"><h2 align="left">Area</h2></td>
        <td width="94"><h2 align="left">Ref:</h2></td>
        <td width="92"><h2 align="left">Job Type</h2></td>
      </tr>
      <?php while(list($id, $jobtitle, $jobtype, $area, $salary, $qualifications, $skills, $jobdescription) = mysql_fetch_array($result, MYSQL_NUM))    { ?>
      <tr class="btnav" onMouseOver="style.backgroundColor='#d8d8d8';" onMouseOut="style.backgroundColor='transparent'">
        <td width="145" align="centre" ><p><a href="jobspecific.php?id=<?php echo $id;?>" target="_self" class="one"><?php echo $jobtitle;?></p></td>
        <td width="92" align="center"><p align="left"><?php echo $area;?></p></td>
        <td width="94" align="center"><p align="left">JOB00SH<?php echo $id;?></p></td>
        <td width="92" align="center"><p align="left"><?php echo $jobtype;?></p></td>
      </tr>
      <?php } include 'library/closedb.php'; ?>
    </table></td>
    <td width="86" valign="top"><table width="91" border="0" cellpadding="5" cellspacing="0" id="Navigation">
      <tr>
        <td width="81"><a href="post_vacancy.php" class="one">Post Job</a></td>
        </tr>
      <tr>
        <td><a href="jobsposted.php" class="one">View Jobs</a></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
The_Anomaly
Forum Contributor
Posts: 196
Joined: Fri Aug 08, 2008 4:56 pm
Location: Tirana, Albania

Re: Paging

Post by The_Anomaly »

I freaking love this pagination implementation.
Yanayaya
Forum Commoner
Posts: 42
Joined: Tue Dec 02, 2008 7:49 am

Re: Paging

Post by Yanayaya »

Its very nice, its implementing it into the code I have that is the issue.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Paging

Post by pickle »

There are lots of paging examples in these boards too if you search for them.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply