tags:

views:

32

answers:

3

$query = "SELECT val FROM table WHERE id = 1"; mysql_query($query);

This returns a single peice of data from the database. all the ways I know how to deal with this data are mysql_fetch_array() and mysql_fetch_assoc() is there a way to deal with 1 peice of data that doesn't involve pulling it into an array?

+1  A: 

Many wrapper libraries offer this, for example, with ADODb, it's simple

$value=$db->GetOne("select val from table where id=1");

It's not hard to roll your own either.

Paul Dixon
A: 

There is mysql_fetch_field which appears to do what you want.

mysql_fetch_field(0,0);
David Dorward
A: 

Hi, you can use this...

mysql_result(mysql_query($query), 0, 0);

second parameter: row, third parameter: field number