problems with mysql_data_seek

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
User avatar
gjb79
Forum Commoner
Posts: 96
Joined: Fri Jul 18, 2003 6:35 am
Location: x <-- (DC)
Contact:

problems with mysql_data_seek

Post by gjb79 »

Is there any way to set up mysql_data_seek to reset the data to the first item in an array based on a variable?

The page loads its content from a single variable that could contain a number from 1-5 or more. So the array (built from an sql table) has 2 columns, the first column contains a number to match the variable number, The second number contains the important information.

If the variable is 1, it will load all the information from the table where the first column is a 1. everything works fine. However when the variable is a 2, and it loads the information where the first column is a 2, I get a warning on mysql_data_seek.

I understand that it means that the data from the array of 2 has no entry that is in the first row of the table.

Is there anyway around this?

Posibly where I can have data seek jump to the first item in the array rather than the first in the table?

Code: Select all

<?php

  while ( $row = mysql_fetch_array($filelist) ) {
  $test_value = $row['ID'];
  echo  "<input name='selectedfile[]' type='checkbox' value='" . $test_value . "'";
	  while ( $row2 = mysql_fetch_array($FiletoPagelist) ) {
	   if ( $row2['file'] == $test_value ) {
	     echo " checked";
	   }
	   echo ">";
	   
	  }
  
  mysql_data_seek ($FiletoPagelist,0);
  }
  ?>
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Strictly speaking data seek doesn't jump to the nth item in an array but the nth row in a database result resource.

If you give it 0 as a the position arg, it will go to the first row in the result resource.
User avatar
gjb79
Forum Commoner
Posts: 96
Joined: Fri Jul 18, 2003 6:35 am
Location: x <-- (DC)
Contact:

Post by gjb79 »

ahh.. and what i need it to do is jump to the first item in the array, not the database result source.

Didn't really realize there was a difference, but now I do.

Thanks!
Post Reply