Jump to content

php/mysql variable question


fallenangel1983

Recommended Posts

Hey all. im having a small difficulty with this question.

 

say im trying to get a specific ID from a table...lets call it tablename

 

ID        NAME

1          GEOFF

2          ANDY

3          BOB

 

so to try and get the specific ID for BOB the mysql would be:

 

$sql="SELECT ID FROM tablename WHERE NAME='bob'";

$result=mysql_query(sql);

 

My question is this: HOW do i then save this ID i have selected into a PHP variable? 

 

i.e. i want to save it as a variable named $bobID and so when i write...

 

echo "$bobID";

 

it reads    3

Link to comment
https://forums.phpfreaks.com/topic/99033-phpmysql-variable-question/
Share on other sites

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.