Mysql select tip

Reply

Join Date: Sep 2008
Posts: 136
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Mysql select tip

 
0
  #1
Oct 11th, 2009
Hai,

I had a mysql database and it contain columns like "id" and "name".

I am using the following query for selecting a name with an id .

My code is

$row=mysql_select("SELECT * FROM table where id='1'") or die(mysql_error());
$result=mysql_fetch_array($ROW);

$name=$result['name'];


It works and my problem is please let me know whether it is the easy way ? Or there is any other way to do this ?


Thanks in advance
Rajeesh
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 190
Reputation: mwasif is an unknown quantity at this point 
Solved Threads: 25
mwasif mwasif is offline Offline
Junior Poster
 
0
  #2
Oct 11th, 2009
This is the way to do. If you need only name from the db, then simply use name in the SELECT statement instead of *.

  1. $row=mysql_select("SELECT name FROM table where id='1'") or die(mysql_error());
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC