473,775 Members | 2,463 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 6476
..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
1183
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
10251
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
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10270
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
10109
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...
1
10051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
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
6718
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
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4017
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

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.