Hai
I had a mysql table and columns like name, address, phone, id.

I need to select only name of a specified id.

Now i am using this code:

$sel=mysql_query("SELECT * from profile where id='$id'")or die(mysql_error()); 
$row=mysql_fetch_array($sel);
$name=$row['name'];

Please let me know whether this is a correct way. If not please help me with a right way

Thanks in Advance
Rajeesh

This way would probably be better and only use one line.

$name = fetch("SELECT `name` FROM profile WHERE `id` = '$id'");

echo $name;
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.