Danny Togaer
Danny Togaer

Reputation: 339

how can i take a column from the database?

mysql_fetch_array returns my rows but I want the colunms, for example :

    $bilgi= mysql_query("SELECT age,wname,slid,sex,c_name FROM user ");
    //echo mysql_errno($con).":".mysql_error($con)."\n";
    while($sutun= mysql_fetch_array($bilgi))
    {

        echo $sutun["age"]." ";
        echo $sutun["wname"]." ";
        echo $sutun["sex"]." ";     
        echo $sutun["slid"]." ";
        echo $sutun["c_name"]."\n"; 

    }

this return me rows i want it to return colonms any idea?

Upvotes: 0

Views: 65

Answers (1)

Jacob
Jacob

Reputation: 43209

$bilgi= mysql_query("SELECT age,wname,slid,sex,c_name FROM user LIMIT 1");

Would only return one row, but I don't think this is what you want? You need a primary key and use that in a WHERE clause to identify the row you need.

$bilgi= mysql_query("SELECT age,wname,slid,sex,c_name FROM user WHERE id=1");

id being the primary key to identify a row.

Upvotes: 2

Related Questions