Forum Moderators: coopster

Message Too Old, No Replies

New User - basic question!

         

mhoctober

7:56 pm on Dec 22, 2005 (gmt 0)

10+ Year Member



All...new to php I have figured out how to create and query a server side mysql db with code that uses an array.

Is someone able to tell me how I can simply select a single value from a table and conactenate this with some text?

I can write the sql etc...I just need to know how to wite the echo statement that outputs a queried vale joined to some text.

Many thanks

Anyango

8:06 pm on Dec 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi There, Welcome to webmasterworld!

that's pretty simple

for example

$sQuery="select * from user";
$sResult=mysql_query($sQuery) or die (mysql_error());
$sRecordSet=mysql_fetch_assoc($sResult);
$id=$sRecordSet['id'];

you can then output $id in any way u want and there are many possible ways for contatination. for example

echo "UserID of the Current User is: ".$id;

another is

echo "UserID of the Current User is: $id";

i guess it's clear. if not? let us know.

ergophobe

7:12 pm on Dec 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have a look through the forum library [webmasterworld.com] for a thread on the Basic of Extracting Data from MySQL.