At 2:17 AM +0000 4/13/01, Mike P wrote:
>Can I use Mysql fetch_row to specify which row i want to get?
>Like---$row[5]=mysql_fetch_row($result) ?
>Mike P
>[EMAIL PROTECTED]
>
Are you talking about a specific row in the mySQL result set? If so,
use the mysql_result() function. However, this function only returns
one column at a time, so you'd have to loop, something like:
$i=0;
unset($row);
while ($Value = mysql_result($ResultId, 4, $i)) {
$row[] = $Value;
$i++;
}
Note I used row # 4 in the mysql_result() call instead of 5, since
(I'm 89% sure) row counts are 0-based.
I'm also pretty sure you CANNOT use mysql_result() to position to the
desired row, then use mysql_fetch_array() or a similar function to
fetch the whole row.
See
http://www.php.net/manual/en/function.mysql-result.php
for more info.
You may be able to use the mysql LIMIT functionality to do what you want:
$Query = 'SELECT * FROM table ORDER BY name LIMIT 4,1';
This grabs the fifth (again, row counts are 0-based) row. See
http://www.mysql.com/doc/S/E/SELECT.html
Incidentally, your original statement
$row[5]=mysql_fetch_row($result);
would simply create a 1-element array $row, with the array index 5.
If this was your first fetch statement, $row[5] would still contain
the first row of the result set.
-steve
--
+----------- 12 April 2001: Forty years of manned spaceflight -----------+
| Steve Edberg University of California, Davis |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+-------------------------- www.yurisnight.net --------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]