PHP.....
I have a mysql table which has two columns: NAME, ADDRESS. i want to assign the both column names into variable.

if i give one column name and it works as below.
$yourfield = "NAME"; //it prints value of NAME column

I want to retrive values of both column. how can i assign both column names to variable $yourfield ????
try1: $yourfield = "NAME, ADDRESS"; //NOT WORKING???
try2: $yourfield = "NAME" , "ADDRESS"; //NOT WORKING???

Thx.

You can use array , like this

$yourfield = array("NAME", "ADDRESS");

Where,

$yourfield[0] => NAME
$yourfield[1] => ADDRESS

If you are fetching records from database you can directly get values using mysql_fetch_assoc. example link

Hi,

you can try like this

$yourfield = "NAME"."ADDRESS";

or if you want to separate the fields with comma then you should try this

$yourfield = "NAME".","."ADDRESS";

hope this will help you out. :)

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.