Forum Moderators: coopster

Message Too Old, No Replies

Adding php code in my page: Prev/Next Page

         

Mtlinfo

6:40 am on May 3, 2007 (gmt 0)

10+ Year Member



Hi,

I tried the best I could to insert the "Previous and Next Page" php code at the bottom of my page by searching online for tutorials but failed to make it work.

I'm not a php programmer. Even though I manage to make most of the code I find in tutorials to work, this time i'm gonna need some help from you guys.

Below is the code for my page. If you can insert the missing parts, that would be very nice of you.

Here's 1 tutorial you could find the "Previous and Next Page" php code to insert in my page's php code.

<snip>

Thanks,

Richard

= = = = = = = = = = = = =
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">

<?php
/**
* Database Connection
*/

$host = 'localhost';
$username = 'username';
$password = 'password';
$database = 'database';
$dbLink = mysql_connect($host, $username, $password);
$dbSelected = mysql_select_db($database, $dbLink);

/**
* Price is the same for all
*/

$Member = '0.00';
$query = "SELECT Member FROM Permanent WHERE id = 0";
$rows = mysql_query($query, $dbLink);
if ($row = mysql_fetch_array($rows)) {
$Member = htmlentities($row['Member']);
}

/**
* Get the ebooks
*/

$query = "SELECT id,Title,Dir,Cover,Description,Retail FROM eBooks limit 3";

$ebooks = '';
$rows = mysql_query($query, $dbLink);
while ($row = mysql_fetch_array($rows)) {
$id = htmlentities($row['id']);
$Title = htmlentities($row['Title']);
$Dir = htmlentities($row['Dir']);
$Cover = htmlentities($row['Cover']);
$Description = htmlentities($row['Description']);
$Retail = htmlentities($row['Retail']);
$ebooks .= <<<ENDOFHTML
<tr>
<td width="120" align="center"><img src="ms/$Dir/$Cover"></td>
<td align="justify"><a href="ms/$Dir/"><font face="verdana" size="+0"><b>$Title</font></b></a>
<br><font face="verdana" size="-1">$Description
<br><font face="verdana" size="-1" color="red">Retail Price: $$Retail</font>
<br><font face="verdana" size="-1">Member's Price: $$Member</font></font></td>
<td width="100" rowspan="2" align="center"><form action="ebookclaim.php" method="POST">
<input type="hidden" name="DWURL" value="$DWURL">
<input type="hidden" name="Title" value="$Title">
<input type="hidden" name="Cover" value="$Cover">
<input type="submit" border="0" name="submit">
</form></td>
</tr>
<tr>
<td colspan="3" align="center"><img src="blueline.jpg"></td>
</tr>
ENDOFHTML;
}
mysql_close($dbLink);
/**
* Static HTML:
*/
?>

[edited by: dreamcatcher at 8:48 am (utc) on May 3, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]

omoutop

11:13 am on May 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



well what you are asking is called pagination... There are thousands of descent tutorials and even ready-made classes for this.

The logic for this is very simple.
1) determine how many products you wish to show per page
2) perform simple query (will all criteria and restrictions) to determine how many products there are in database, and thus how many page you gonna show
3) build a query using the LIMIT x,y option (x: how many products to show, y: the number of record to start showing)
4) put the html table of showing products into a large loop that checks the page you are in vs the max number of pages.
5) Below loop and outside of it, build your prev-next links.
6) check if the total pages are greater than 1, and if yes, show prev/next links, plus the pages in-between

These are just general guidelines that will help you get started

Mtlinfo

1:35 pm on May 3, 2007 (gmt 0)

10+ Year Member



well what you are asking is called pagination... There are thousands of descent tutorials and even ready-made classes for this.

The logic for this is very simple.
1) determine how many products you wish to show per page
2) perform simple query (will all criteria and restrictions) to determine how many products there are in database, and thus how many page you gonna show
3) build a query using the LIMIT x,y option (x: how many products to show, y: the number of record to start showing)
4) put the html table of showing products into a large loop that checks the page you are in vs the max number of pages.
5) Below loop and outside of it, build your prev-next links.
6) check if the total pages are greater than 1, and if yes, show prev/next links, plus the pages in-between

These are just general guidelines that will help you get started

You are missing the point my friend.

I already know about the LIMIT option and the tutorials out there about pagination (I even posted a link pointing to one before a moderator removed it).

That's not the problem here, my problem is to take this php pagination code and put it inside the php code I pasted above as I am not a php programmer.

I tried surfing the net for these tutorials, don't get me wrong but since i'm not a programmer, this is as far as I can take it and that's why you see me here asking for help.

If you have such pagination php code, please insert it above in my php code and I will save it on my website.

Thanks,

Richard