473,387 Members | 1,890 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,387 software developers and data experts.

resetting the result of a mysql query

tolkienarda
316 100+
Hi all
how would i go about reseting the internal pointer in a mysql_query result

I use a loop to display the results of a colom in a select box
here is the loop
Expand|Select|Wrap|Line Numbers
  1.         $i=1;
  2.             while ($i<=$row)
  3.             {
  4.                 $row2=mysql_fetch_row($result);
  5.                 echo '<option value="', $row2[1], '">', $row2[2], '</option>';//outputs the unique login name
  6.                 $i++;
  7.             }
  8.  
now i resuse this code with different variables here it is
Expand|Select|Wrap|Line Numbers
  1.         $k=1;
  2.         reset($result);
  3.             while ($k<=$row)
  4.             {
  5.                 $msrow=mysql_fetch_row($result);
  6.                 echo '<option value="', $msrow[1], '">', $msrow[2], '</option>';//outputs the unique login name
  7.                 $k++;
  8.             }
  9.  
as you can see i've used the reset() function but it dosen't seem to work

thanks for any help

eric
Jan 18 '07 #1
5 4352
ronverdonk
4,258 Expert 4TB
You have to use the mysql_data_seek() command (reset() is for arrays).
[php]$reset = mysql_data_seek($result, 0);
if (!$reset)
echo 'MySql data seek Error' . mysql_error();
$k = 1;
while ($k<=$row)
{
... etc ...[/php]Ronald :cool:
Jan 18 '07 #2
tolkienarda
316 100+
thanks

and on a side note where can i get the source of functions like reset() and other prebuilt functions. as i learn more about php i would like to start learning the details

thanks again
eric
Jan 18 '07 #3
ronverdonk
4,258 Expert 4TB
You better do some PHP tutorials on the web. All the php functions can be found in the standard PHP documentation at www.php.net. Good luck.

Ronald :cool:
Jan 18 '07 #4
tolkienarda
316 100+
I've done several of the tutorals like on w3cschools and here as well as several others and even a lynda.com training video but if there are more you can sugges that would be great
Jan 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item,...
13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
0
by: Doug Reese | last post by:
hello, i have what seems to me a very common operation i'm performing. i need to find the balance on an invoice. i was not having any problems until the production server was upgraded to mysql...
2
by: Belmin | last post by:
Hi all, Wanted to know what is the most efficient way of doing a select query for mysql that only returns one value. For example: $mysqli->query('select count(*) from log'); $temprec =...
4
by: Bob Bedford | last post by:
We have no access to a mysql NG on my provider's server, so we ask here: We have a long query (long in text) with a UNION between 2 select. We have been informed that some times the query...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
1
by: automation | last post by:
There is a truncation error of my Web Application using PHP 5.04, MySQL 5.022, and HTML(IE 6.0) whereby the MySQL Result Set is being truncated on the HTML page, even though the CSS Div Page Height...
5
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.