Create an array and go through the array as needed.
Here is some code from one of my db functions:
$DB_RESULT = @mysql_query($sql) or die("Error executing query: " .
mysql_error());
// create an empty array to fill with data
$arrData = array();
$rowCount = 0;
while ($r = mysql_fetch_array($DB_RESULT, MYSQL_ASSOC)){
foreach ($r as $key => $value){
$arrData[$rowCount][$key] = $value;
}
$rowCount++;
}
then simply instead of your code:
while($array = mysql_fetch_array($result)){
use this:
for ($i=0;$i<count($arrData);$i++){
$arrThisRow = $arrData[$i];
$arrNextRow = $arrData[$i+1];
}
obviously, if you are trying to access a variable which index does not
exist, you will need to implement some sort of error checking, etc
adam
> Using mysql, how do I access the data of the next row using code
> something like this:
> $result = mysql_query("select column from table where
> whatever='whatever'");
> while($array = mysql_fetch_array($result)){
> //Whatever
> }
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php