Re: problem with mysql_fetch_array
| From: | Hannes Magnusson | Date: | Thu, 12 Aug 2004 17:18:26 +0000 |
| Subject: | Re: problem with mysql_fetch_array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193610@lists.php.net to get a copy of this message | ||
On Thu, 12 Aug 2004 10:04:00 -0700
papercrane@gmail.com (Justin Patrin) wrote:
> On Thu, 12 Aug 2004 09:20:44 -0400, Deepak Dhake
> <dhaked@mail.rockefeller.edu> wrote:
> > $query4 = mysql_query("SELECT result FROM TBL_result WHERE survey_no=2";
> > while($row2 = mysql_fetch_array($query4)) {
> > //print array
> > }
> >
> > this will print whole array. i just want to print a row at a time and it should be in the
> > loop because i am printing other things as well. can you tell me how to print a row at a time.
> > actually as i explained earlier, i am able to print a row at a time but when it becomes i=1 and
> > starts outer loop for the second time it just printing the same values. any suggestion?
> >
>
> I think you're getting your terminology mixed up. $row2 is an array
> which corresponds to a row in the database. Yes, this will print all
> of the returned records, but I can think off very fe wtimes where you
> don't want to do that.
>
> This loop *is* what you want. Tell us what you're trying to do and
> we'll try to help.
>
$query4 = mysql_query("SELECT result FROM TBL_result WHERE survey_no=2";
$row2 = mysql_result ( $query4, 0 );
or
$i = 0;
while ( $row2 = mysql_result ( $query4, $i++ ) ) {
echo $row2;
}
Looking for this?
- Hannes