Something that stands out is one of your links:
if ($screen > 0)
print <a href=\"view.php?$screen=".( $screen+1)."\"><<Previous
The '$' in '?$screen' is probably not helping, as that'll probably translate
to '?0=1' (or similar).
And, don't you want that to be ($screen - 1)??
Depending on what version of PHP you're running.
You're assuming that $screen will equal $_GET['screen'].
Which, since 4.2.0 and with default settings, is a bad assumption.
if ($screen != $_GET['screen']) $screen = $_GET['screen']; // or just use
There's a register_globals setting you can change (default is false):
But, changing it to true also has security implications:
Then again, you're also referencing a lot of variables that aren't defined
in your example.
So, it's hard to know what you may be doing that you just didn't post.
You're basing $pages on the ceil([number of rows] / [rows per page]).
Problem with this, the LIMIT won't allow [number of rows] to ever be greater
than [rows per page].
So, $pages will never be anything besides 0 or 1.
You may want to try running a 2nd, similar query, without the LIMIT, using
(just in case: http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html)
You have an extra '}' after the while scope that doesn't line up with
Since you stated the page loads, I'm assuming that's just because it's a
- Jon L.
On Thu, Apr 3, 2008 at 6:57 PM, Nasreen Laghari <[EMAIL PROTECTED]>
> I'm trying to put limit of data fetch as well as dynamic navigation. Below
> is the try which I did but something is going wrong as $screen value is not
> increasing so when I click on NEXt button it refreshes the same page and
> Previous button does even show.
> Could you kindly have look on the coding and help me where i'm mistaking.
> $rows_per_page = 10;
> if (!isset($screen))
> $start = $screen * $rows_per_page;
> $sql = "SELECT * FROM gig g, venue v WHERE g.gigName LIKE
> '%".$gig_name."%' OR g.gig_date LIKE '%".$sdate."%' OR g.genre LIKE
> '%".$genre."%' OR g.ticket_price LIKE '%".$ticket_price1."%' OR
> g.ticket_price LIKE '%".$ticket_price2."%' OR v.venueName LIKE
> '%".$vname."%' OR v.vCity LIKE '%".$city."%' order by gig_Date LIMIT
> $result = mysql_query($sql) or die("Query error: ". mysql_error());
> $num_rows = mysql_num_rows($result) ;
> $pages = ceil($num_rows / $rows_per_page);
> while ($row = mysql_fetch_array($result))
> global $limit;
> $j = $j+1;
> $gigid = $row['gigid'];
> $gigname = $row['gigName'];
> $sdate = $row['gig_fdate'];
> $fdate =$row['gig_tdate'];
> $genre = $row['genre'];
> $ticket_price = $row['ticket_price'];
> $gigdetail= $gigid;
> echo("<br> $gigid <a href='detail.php?gigDetail=$gigid'>
> if ($screen > 0)
> print <a href=\"view.php?$screen=".( $screen+1)."\"><<Previous
> Entries</a> ";
> else if ($screen < $pages)
> $screen = $screen+1;
> print "<a href=\"view.php?screen=".($screen)."\">Next Entries>></a> ";
> You rock. That's why Blockbuster's offering you one month of Blockbuster
> Total Access, No Cost.