Hi I had a database . I need to take one of the cell content into an array. I had code but not working

$select=mysql_query("SELECT * from db where name='rajeesh'") or die(mysql_error());
	  $new=mysql_fetch_array($select);
	  $forfriends=$new['first'];
	 $forf=array ($forfriends);
 	  while (list ($key, $val) = each ($forfriends)) {
echo "$key -> $val <br>";
}

But this is not working.. Please help me
And thanks
Rajeesh

If you are retrieving the value of just one column then the following will do the trick. Just adjust the $column variable to the column name.

$select=mysql_query("SELECT * from db where name='rajeesh'") or die(mysql_error());
$column='first'; //set the column name
for ($key=$column;$row = mysql_fetch_array($select),$val=$row[$column];) {
echo "$key -> $val <br>";
}
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.