Page 1 of 1

problems with mysql_data_seek

Posted: Wed Dec 03, 2003 7:08 pm
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);
  }
  ?>

Posted: Fri Dec 05, 2003 1:05 pm
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.

Posted: Fri Dec 05, 2003 2:36 pm
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!