Re: global variable declaration

From: Date: Wed, 08 Feb 2006 14:57:53 +0000
Subject: Re: global variable declaration
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230091@lists.php.net to get a copy of this message
On 8 Feb 2006, at 14:46, suresh kumar wrote:
       this is my sample code:
                        i am having user table  with SponsorID as one field in mysql  database,this is my query;
      for($j=0;$j<5;$j++):
       $result=mysql_query("select * from user where SponsorID='$id[$j]' ");
      endfor;
      in  above code when i   print  mysql_num_rows($result) inside for loop its output is  5.when i  print outside the for loop its o/p is 0.I searched weberdev.com website  and declared  $result as global.but same output 0.i want $result  variable to be  available outsibe the forloop and  all other  part of my code.i am looking forward suggestions from ur side.
$result is being over-written each time it goes through the for loop. So it will only ever contain the value of SponsorID=$id[4], which if empty will mean the number of rows inside $result will be zero. Cheers, Rich -- http://www.corephp.co.uk Zend Certified Engineer PHP Development Services

« previous php.general (#230091) next »