Re: [PHP-DB] Dynamic Navigation with Limit
1) Something that stands out is one of your links: if ($screen > 0) { print < "; } 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)?? 2) 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 the assignment. There's a register_globals setting you can change (default is false): http://php.net/ini.core#ini.register-globals But, changing it to true also has security implications: http://php.net/security.globals 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. 3) 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 COUNT(*). (just in case: http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html) 4) You have an extra '}' after the while scope that doesn't line up with anything. Since you stated the page loads, I'm assuming that's just because it's a snippet. - Jon L. On Thu, Apr 3, 2008 at 6:57 PM, Nasreen Laghari <[EMAIL PROTECTED]> wrote: > Hi, > > 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. > > Regards > > Nasreen > > > $rows_per_page = 10; > $i=0; > if (!isset($screen)) > $screen=0; > $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 > $start,$rows_per_page"; > $result = mysql_query($sql) or die("Query error: ". mysql_error()); > $num_rows = mysql_num_rows($result) ; > $pages = ceil($num_rows / $rows_per_page); > $j=0; > 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(" $gigid > $gigname"); > } > > } > > if ($screen > 0) > { > print < Entries "; > } > else if ($screen < $pages) > { >$screen = $screen+1; > print "Next Entries>> "; > } > > ?> > > > > > > You rock. That's why Blockbuster's offering you one month of Blockbuster > Total Access, No Cost. > http://tc.deals.yahoo.com/tc/blockbuster/text5.com >
[PHP-DB] Dynamic Navigation with Limit
Hi, 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. Regards Nasreen $gigid $gigname"); } } if ($screen > 0) { print <> "; } ?> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com
Re: [PHP-DB] php4 to php5
Sounds like you're talking about the register_globals functionality. It's a php.ini setting that will cause $_POST['foo'] or $_GET['foo'] to be copied to the global variable $foo. This is somewhat of a security risk, thus disabled by default. There's another superglobal array that you might find useful: $_REQUEST. $_REQUEST consists of variables from $_GET,$_POST,$_COOKIE (in that order, I believe). http://us3.php.net/manual/en/reserved.variables.php http://us3.php.net/manual/en/ini.core.php#ini.register-globals --GREG (note:I also posted this to the php-general list as it isn't a db-related topic.)
[PHP-DB] php4 to php5
I suppose I am behind the time in migrating from php4 to 5. That said, my main problem is getting variables recognised. I can see how to do it - you need to identify all the variables that could be sent from the page and then assign a name, as in $myvar=$_GET['myvar'] and ditto for POST variables if any. Is there a function to convert all get and post variables to $_GET and $_POST, or is that a security concern? The further I have got is this: function php5($var) { if(ISSET($_POST[$var])&&$_POST[$var]<>"") { $newvar=$_POST[$var]; } else { $newvar=$_GET[$var]; } return $newvar; } $input_variable=php5('input_variable'); however I would like to do this for all variable, I tried iterating through the $_GET and $_POST arrays but could not get it to work. Anyway the main reason I am writing is: - where the web page form uses the POST method, but there are parameters in the URL after the ? sign, these 'get' parameters seem to stay there when you submit the form from eg button. So, let's say the script will add a line if addlines=y, if before you submit the form you have ?addline=y in the URL you will continue to add lines according to the script even though there is no hidden variable on the page called 'addline', because every time you submit the form with POST you have addline=y in the URL - if the script looks at GET variables then this will feed into the script. This does not seem to happen with php4 - if the page does not submit an 'addline' variable from a form field, it will not feed into the script. So what's the rationale for that (the URL submitting the variables) and what is the usual solution? The problem arises on this particular page because of a mix of buttons, some are javascript and send the addline=y with onClick. John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php