Welcome visitor
* Login
* Register
It is currently March 21st, 2019, 11:51 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP



Post new topic Reply to topic  [ 5 posts ] 
Author Message
  retrieveing info from MySQL into Php
PostPosted: February 6th, 2009, 12:52 am 
User avatar

Posts: 137
hello you guys,
i have a question about this php syntax im using, i supposed that this should echo the value of the field name that is within mysql table, so can you tell me why this is not working? thank you in advanced

$db_table=mysql_query("SELECT * FROM userss WHERE name LIKE '$userName' ");
echo $db_table['name'];


Top
 Profile  
 
  Re: retrieveing info from MySQL on Php
PostPosted: February 6th, 2009, 12:59 am 
User avatar

Posts: 79
Ok, i see whats goin on.... the thing is that the first line you have there does not create an array, it is an unusable bunch of data, here are the lines to convert it to an array and then echo'ing the values from the array..
$row=mysql_fetch_array($db_table);
echo $row['name'];


Top
 Profile  
 
  Re: retrieveing info from MySQL into Php
PostPosted: February 9th, 2009, 8:23 pm 

Posts: 46
Ok, now I have another question,

and what about if I want to print more than one field, lets say, all the info of that user?


Top
 Profile  
 
  Re: retrieveing info from MySQL into Php
PostPosted: February 9th, 2009, 8:28 pm 
User avatar

Posts: 86
What I would do on that case is extract the values from the just created array and then alll the variables would be available. Remember that the names for the variables is the same than the field name on the MySQL table.


Top
 Profile  
 
  Re: retrieveing info from MySQL into Php
PostPosted: February 9th, 2009, 8:30 pm 

Posts: 46
Thanks man, thats awsome!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

FORUMS » Server Side » PHP


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron