Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

mysql_fetch_array($result) ??

Codes here !

Moderators: macek, egami, gesf

mysql_fetch_array($result) ??

Postby fluff » Tue Jan 28, 2003 4:21 am

Hi, Does anyone know how I can use the above function twice in one page on the same query?

At the top of the page I have something like the following....
#-----------------------------
$DBresults=mysql_fetch_array($result)
$LastModified= $DBresults['lastModified'];
#----------------------------

But then further down the page I want to use a loop to return multiple assignments of variables, but if I try to retrieve them using...
#-----------------------------
$comments=mysql_fetch_array($result)
$comments= $DBresults['comments'];
#----------------------------

I do not get the results I require. If I comment out the first instance, there isn't a problem ???

Is there another way of doing this :?:
Thanks
fluff
New php-forum User
New php-forum User
 
Posts: 7
Joined: Thu Dec 19, 2002 8:43 am

Postby Joan Garnet » Tue Jan 28, 2003 3:11 pm

kepp the value in a variable and then use it whenever you want.
Code: Select all
$DBresults=mysql_fetch_array($result)
$LastModified= $DBresults['lastModified'];
$comments= $DBresults['comments'];
.
.
.
.
.
echo $comments;


Does it help?
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron