Home  |  Linux  | Mysql  | PHP  | XML
From:Nasreen Laghari Date:Fri Apr 25 02:58:22 2008
Subject:A very basic PHP question
Hi,
   
  I have some confusion with Variables scope. I searched but couldn't figure it out :(
   
  The question is:
  one variable which changes according to if... else statment, how do you change the value of that variable?
   
  Actually $query is changing on $type variable so I tried doing using if.. else statment. Please clarify me.
   
  function select_entries_quick ($offset=0,$location,$type)
{
 
 global $limit;
 $query;
 $date = date("d/m/y");

   if (empty($offset)) { $offset = 0; }
   if($type=="today")
 {
  $query = "SELECT * FROM gig where gig_Date= $date";
 }
 else if($type=="tomorrow")
 {
  $tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
   $query = "SELECT * FROM gig where gig_Date= $tomorrow";

 }
 else if($type=="week")
 {
  $week  = mktime(0, 0, 0, date("m")  , date("d")+6, date("Y"));
  $query = "SELECT * FROM gig WHERE g.gig_Date <= ".$date." OR g.gig_Date >=".$week.";
  
 }
 
 $result = safe_query($query);
 
 
   return $result;
  }
 

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
Navigate in group php.db at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants