TABLE_ROWS
13
1
8
5
2
3
5
2
7
6
3
4
3
32

my select query results a table like this .Here i want to assign each item to each variables .
a=13
b=1 etc...

i tried with forech but i did not get out put.Here is my code

$sql="SELECT TABLE_ROWS
    FROM `information_schema`.`tables` 
    WHERE `table_schema` = 'labreport'";
    $result= mysql_query($sql);

    $row = mysql_fetch_row($result);
    echo $row[0];

echo $row[1];

If you have a fixed number of variables (known in advance and equal to the lenght of the $row) you could use the list function. Something like:

list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m) = $row;

But be aware that using an array instead of lots of variables is often more practical and handy.

And please note the mysql_* functions are deprecated (use PDO or mysqli).

commented: Another mysql caveman! +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.