Link to home
Start Free TrialLog in
Avatar of john80988
john80988

asked on

php get value of specific row and column from array of db

say i retrive a table select * from xxxxx

if there any simple way that say

$value = $dataRecord...; ( which i can direct specific a row and column )

like row 0 column 1 or row 0 column "title"

expert please help
ASKER CERTIFIED SOLUTION
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hello, yes you can use the  PH{  mysql_data_seek( )  function to set the mySQL Result to any specific numbered Row , you should read this in the manual -
http://us2.php.net/manual/en/function.mysql-data-seek.php

some code might be like -
$result = mysql_query("");
$query = 'SELECT * FROM xxxxx';
$result = mysql_query($query);
if (mysql_data_seek($result, 4)) {// go to row 4
    $row = mysql_fetch_assoc($result),
    }
    else // if the seek Fails then there is NO row 4
    {
    echo "Cannot seek to row 4: " . mysql_error() . "\n";
    }

Open in new window

but you can get different amount of rows from a select, You may need to use the   mysql_num_rows($result) to get the Range of the amount of rows
Avatar of Dave Baldwin
Because MySQL will 're-use' empty space in it's tables, the order of rows is only predictable if you use an ORDER BY clause.  ORDER BY tells MySQL to sort the results by a particular column and return them in that order.  If your table is having additions and deletions, the data you are looking for will not necessarily be in the same numerical row each time.

It is usually best to find a different way to identify the data you want to retrieve.