I'm tierd of FETCHING

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gotlisch
Forum Newbie
Posts: 23
Joined: Wed Jan 11, 2006 8:37 am

I'm tierd of FETCHING

Post by gotlisch »

Hi Guys,

I have a bit of a problem. Like most people I like to use mysql_fetch_array($result, MYSQL_ASSOC))
in combination with a While loop to print out data.

The problem is that I want to use the fetch function twice on the same result, to print two different tables
and as you know by the time the first one is done the fetch function will return false.

I "solved" the problem like this:

Code: Select all

$result = mysql_query($query)
$result2 = mysql_query($query)
But that doesn't look very pretty, and isn't very efficient.

Is there a way of re-setting the pointer so that I can re-use the fetch function on the same
result? Or is there some other solution.

Cheers!


Mikael
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_data_seek()

or you could store the results into an array for use across both instances.
gotlisch
Forum Newbie
Posts: 23
Joined: Wed Jan 11, 2006 8:37 am

Post by gotlisch »

Cheers Mate!

That did the trick!
Post Reply