Re: query strings coming from the same page going back to the same page

From: Date: Sat, 10 Apr 2004 22:33:58 +0000
Subject: Re: query strings coming from the same page going back to the same page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-183088@lists.php.net to get a copy of this message
Andy B schrieb:
was wondering if this would work or do i need different code: <?php include("libs/conf.db"); if(($_GET['month']==0)||($_GET['month']>12)){ $query="SELECT Type, StartDate, EndDate, Name, County, Notes FROM $EventsTable ORDER BY StartDate DESC"; } else { $query="SELECT Type, StartDate, EndDate, Name, County, Notes FROM $EventsTable WHERE StartingMonth='{$_GET['month']}' ORDER BY StartDate DESC";} mysql_pconnect($host, $mysqluser, $mysqlpwd)||die(mysql_error()); $result=mysql_query($query) or die(mysql_error()); ?> then i would have a link on the same page this code came from: <a href="ViewEvents.php?month=1">Jan</a> the link is supposed to reload the same page it came from and be bart of the query above... the thing im not sure of is if that will work or not or do i need something else...(new to self referrencing pages)...
Probably it is better to use <a href="<?php echo $_SERVER['PHP_SELF']; ?>?month=1">Jan</a> Then it is not in dependency to the filename. And btw. you should check with is_numeric() if the value from $_GET['month'] is really a number or you will have an security hole in you script. Rainer

« previous php.general (#183088) next »