Help - Search - Members - Calendar
Full Version: Display Multi pages
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
ssmony
Pls can some one help me, what's wrong with this code, it's connect to database but just coul not display next page or previous.
(This code from someone else, I try it but not work)

<?php

$rown="3"; //number of rows to be display each page
$query="SELECT * FROM products";
$result=mysql_query($query);

$numrows=mysql_num_rows($result);//total number of rows equal to $trows;

if(!isset($start)) { // This variable is set to zero for the first page
$start = 0;
}

print 'start = ' & $start;

$query ="$query limit $start,$rown"; //limit output $rown=5 rows starting $start
$result=mysql_query($query);
print"<table border=0>
<tr>
<td>Product id</td>
<td>Product name</td>
<td>Product group</td>
<td>Picture name </td>
</tr>";
while ($row=mysql_fetch_array($result)) {
print"<tr>
<td>$row[0]</td>
<td>$row[1]</td>
<td>$row[2]</td>
<td>$row[3]</td>
</tr>";
}
print"</table>";
print"<table><tr>
<td>".first($start,$numrows,$rown)."</td>
<td>".previous($start,$numrows,$rown)."</td>
<td>".next1($start,$numrows,$rown)."</td>
<td>".last($start,$numrows,$rown)."</td>
</tr></table>";

print 'start1 = ' & $start;

//============================================================

?>
UnrealMedia
I might sound a bit stupid for this, im only a PHP beginer. But you havent echoed the next, previous, ect...

Not really sure to be honest.
023-jimmy
QUOTE (UnrealMedia @ Sep 12 2008, 11:10 PM) *
I might sound a bit stupid for this, im only a PHP beginer. But you havent echoed the next, previous, ect...


Actually 'print' does the same as 'echo' biggrin.gif

Now on to the problem. If there is false, not working, cracked code in the block the whole code won't work. While quickly looking through your code. I already spotted this:

CODE
print 'start1 = ' & $start;


It's code that doesn't make any sense. And is invalid. It should be like this:

CODE
print 'start1 = '. $start;


Just browse through your code and try to find more invalid code. Like maybe you forget to close lines ( ; ).
derek.sullivan
ehh use echo instead of print...

anyways, search P2L tutorials for pagination...

If you don't, I took the liberty to finding the link to the tutorial for you...

I've used it everytime I use the pagination.. Never went wrong with it. Gotta change a few things. that's about it.

anyways here is the link: http://www.pixel2life.com/publish/tutorial...n_to_your_site/
Jagmeet Singh
yes m also looking paging tutorials !!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.