Jump to content

Recommended Posts

$count     = "SELECT latest_id FROM cm_latest ORDER BY ABS(latest_id) LIMIT 2";
$count_out = mysql_query($count)
        	or die("This script was unable to execute the SQL Query Count. Please
        	contact the webmaster and inform them of the problem. Sorry for the
       		inconvience.");
$numrows1 = mysql_num_rows($count_out);

$query1   = "SELECT latest_id FROM cm_latest ORDER BY ABS(latest_id) LIMIT 2";
$result1  = mysql_query($query1)
        	or die("This script was unable to execute the SQL Query #1. Please
        	contact the webmaster and inform them of the problem. Sorry for the
       		inconvience.");
$object1  = mysql_fetch_array($result1);
extract($object1);

echo $latest_id[0];
echo "<br />";
echo $latest_id[1];
echo "<br />";
echo $numrows1;
exit();

 

That doesn't work. It doesn't print the value of latest_id[1].

I retrieved two rows and two values, how do I access the second value?

Link to comment
https://forums.phpfreaks.com/topic/53910-accessing-mysql_fetch_array/
Share on other sites

try

<?php
$query1   = "SELECT latest_id FROM cm_latest ORDER BY ABS(latest_id) LIMIT 2";
$result1  = mysql_query($query1)
        	or die("This script was unable to execute the SQL Query #1. Please
        	contact the webmaster and inform them of the problem. Sorry for the
       		inconvience.");
$latest_id = array();
while ($object1  = mysql_fetch_array($result1)) {
    $latest_id[] = $object[0];
}


echo $latest_id[0] ;
echo '<br>' ;
echo $latest_id[1] ;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.