Jump to content


Display Multi pages


4 replies to this topic

#1 ssmony

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 10 September 2008 - 09:28 PM

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;

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

?>

Edited by ssmony, 11 September 2008 - 04:27 AM.


#2 UnrealMedia

    Young Padawan

  • Members
  • Pip
  • 72 posts

Posted 12 September 2008 - 04:10 PM

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.

#3 023-jimmy

    Young Padawan

  • Members
  • Pip
  • 44 posts

Posted 13 September 2008 - 01:57 PM

View PostUnrealMedia, on Sep 12 2008, 11:10 PM, said:

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' :flowers:

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:

print 'start1 = ' & $start;

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

print 'start1 = '. $start;

Just browse through your code and try to find more invalid code. Like maybe you forget to close lines ( ; ).

Edited by 023-jimmy, 13 September 2008 - 02:07 PM.


#4 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 13 September 2008 - 10:17 PM

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/

#5 Jagmeet Singh

    Young Padawan

  • Members
  • Pip
  • 1 posts
  • Gender:Male
  • Location:India

Posted 16 May 2009 - 12:20 AM

yes m also looking paging tutorials !!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users