473,231 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

multiple mysql_fetch_array() calls

Hi All,
I've got a simple query hopefully somebody can clear up for me. I need to
make a query on a database to select a set of table rows, using something
like:

$result = mysql_query($query);

I can then use mysql_fetch_array in a while loop to access each row in the
result. This all works fine.

However, what I'd like to do is to go through this result more than once.
ie. use mysql_fetch_array() to go through each row in $result more than
once. How do I do this?. There appears to be no my of resetting
mysql_fetch_array back to the beginning of the $result once all rows have
been erad once.

I don't want to make multiple identical queries on the database, simply to
read the same information.

Any ideas?.

Ta,
Dave
Jul 17 '05 #1
2 6074
Dave Moore wrote:
Hi All,
I've got a simple query hopefully somebody can clear up for me. I need to
make a query on a database to select a set of table rows, using something
like:

$result = mysql_query($query);

I can then use mysql_fetch_array in a while loop to access each row in the
result. This all works fine.

However, what I'd like to do is to go through this result more than once.
ie. use mysql_fetch_array() to go through each row in $result more than
once. How do I do this?. There appears to be no my of resetting
mysql_fetch_array back to the beginning of the $result once all rows have
been erad once.

I don't want to make multiple identical queries on the database, simply to
read the same information.

Any ideas?.

Ta,
Dave

Store your first time result in your own query.. and then just loop your
own query as many times as needed...

$yourArray = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC) {
$yourArray[] = $row;
}

then just do this as many times as needed...

foreach($yourArray as $rowNum => $row) {
//$row would be same as the original $row inside the while loop
inside this loop.
}
Jul 17 '05 #2
You can also use this:

mysql_data_seek ($result, 0);
http://us4.php.net/manual/en/functio...-data-seek.php

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bill | last post by:
Hi, This looks like a simple problem, but I just can't seem to wrap my head around it. I'm trying to build a table dynamically, based on a result set from mysql. There will be 9 results for a...
15
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
0
by: LS | last post by:
1. When I select an assignment, the class roster disappears. I don't want it to show up until I select an assignment. 2. I want to be able to enter grades and submit all with only one submit...
1
by: LS | last post by:
1. When I select an assignment, the class roster disappears. I don't want it to show up until I select an assignment. 2. I want to be able to enter grades and submit all with only one submit...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
1
by: abhishekhs | last post by:
Hi all I have more than one multiple select lists in a page. Something like this <tr> <td> <select NAME="StrainList" ID="StrainList" SIZE="5" multiple="multiple" style="width: 150px"> <?...
1
by: quill | last post by:
Hi I am making a chatroom script and it appears that the problem seems to be that my setTimeout's are conflicting. The logic is as follows: Run a login check every x seconds Run a trigger...
2
by: dylanhughes | last post by:
I'm looking for an example of a login system that has multiple fields (2 to be exact) + password. e.g username, company name and password, the user, company and password are checked against a mysql...
8
by: obtrs | last post by:
show data of multiple tables? i have 3 tables i want to show the data from them to a page. table1 "trip" table2 "seat" table3 "user_information" show all the data of table one which is...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.