473,788 Members | 2,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reset pointer for mysql_fetch_arr ay($sth)

I'm needing to traverse my $sth twice:

list($date_foun d, $junk) = mysql_fetch_row ($sth);

while (list($date, $stuff1, $stuff2) = mysql_fetch_arr ay($sth)) {
// do stuff
}

But of course, when I do this then the WHILE loop starts at 1 instead
of 0 because mysql_fetch_row leaves the internal pointer at 1. I tried
reset($sth), but this just gives an error that $sth isn't an array.

Is there a way to reset the internal pointer without running a new
query?

TIA,

Jason
Dec 12 '07 #1
1 6477
..oO(Jason Carlton)
>I'm needing to traverse my $sth twice:

list($date_fou nd, $junk) = mysql_fetch_row ($sth);

while (list($date, $stuff1, $stuff2) = mysql_fetch_arr ay($sth)) {
// do stuff
}

But of course, when I do this then the WHILE loop starts at 1 instead
of 0 because mysql_fetch_row leaves the internal pointer at 1. I tried
reset($sth), but this just gives an error that $sth isn't an array.

Is there a way to reset the internal pointer without running a new
query?
There's mysql_data_seek (), but why not simply fetch all the data into an
array first and then loop through it as often as you want? That would be
more reliable and portable.

Micha
Dec 13 '07 #2

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

Similar topics

3
1621
by: Chris | last post by:
I have a SELECT * query that returns info such as 'name', 'date', 'cost', and 'notes'. At the head of this query return it reads how many records were found. I would like to append that with 'how many records were found at a cost of' ... But haven't been able to find a means of totalizing the 'cost' column in my query. Does anyone have any ideas on how this might be accomplished ??? I've spent considerable time on the net looking at...
3
20524
by: JoTo | last post by:
Hi Group, sorry for my for you surely dumb question. But i'm not so familiar with this reference- and pointerstew in C++ yet. Let me explain my problem with a little Codesnippet. If i do the following: void CServerSock::OnAccept(void)
0
1185
by: Georg D. | last post by:
hi, with struct C { string f1; }; class A
1
267
by: Georg D. | last post by:
hello, with struct C { string f1; }; class A
4
4739
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC 14882:2003(E) §8.5 says:   To zero-initialize an object of type T means: 5   -- if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T;
9
2318
by: starbuck | last post by:
Hi, have a form, with a text input "fieldname". method POST $var = $_POST $var is then used to search in mysql select * from table where jobtype like '$var%'
4
6475
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to define the servername / hostname in my Perl Progrem.. Here is the code:
10
10254
by: Xinyi Yang | last post by:
Hi, I have to read information out of a file. The format will be string1,string2,..., string3,string4,..., .... (the string sould not contain ' ' anyway) the size of each string is uncertain. I plan to create an array to contain the pointers to the strings. Yet I don't know how to read a string out from the file any let a pointer point to it. I thought about using char *p=(int *) (malloc(n*(sizeof(char)))), but it means I have to first...
1
2128
by: utab | last post by:
Hi Is there way to go to the start character of the the proceeding line while reading from a file. (Sth like working '\n' but immediately will take me one line down) Lets say; my file is abcdefghkl 123 23 43 54
0
10374
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5539
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.