Jump to content

Assigning values from table queries to variables


diode

Recommended Posts

Ok I am progressing alright in php.

I thought I almost had it when I hit a wall. I have two new problems:

1) I suddenly realized that I need to query a table and place the values in the fields that are in the table into variables

And 2) I want the person's username/time msg was posted/ and other misc stuff on the top line of a post, and the message body on the second line of a user's post. But how in the world would I pick out certain data and put it in its own row?

I have looked all over the web for tutorials and other faqs but I not sure on what I need to look for in order for these to work.

As always, thanks in advance :),
diode

Well!

Your first problem is to assign the contents of  db to other variables!

See this one..

[code]

$sql="select one,two from table_name [where_caluse] ";

$qry=mysql_query($sql) or die (mysql_error()); # here i am assuming that you had only one row.

$result=mysql_fetch_array($qry);

$var_one=$result['one'];
$var_two=$result['two'];

[/code]


First let us know this is the same you want for the first problem or not.If it is not i would like to know little more description about your problem.

Regards
Joshi.

Oh! So you recommend typing out all the fields instead of just * (all)? That would make sense lol.

That might work. It's late now so I have to go to bed I'll try it in about 20 hours when I am off work lol.

Thanks for your quick response :D
diode

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.