very simple mysql question!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shou0630
Forum Newbie
Posts: 3
Joined: Sun Nov 22, 2009 2:35 pm

very simple mysql question!!!

Post by shou0630 »

I know

Code: Select all

SELECT * FROM Persons
WHERE LastName='peter'
works.But how do i make a var work like???

Code: Select all

 SELECT * FROM Persons
WHERE LastName='$_POST[name]'
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Re: very simple mysql question!!!

Post by morris520 »

put your query as a string then pass to php func mysql_query

Code: Select all

$query = 'SELECT * FROM table WHERE id = ' . $_post['id'];
Hope this helps

Morris
shou0630
Forum Newbie
Posts: 3
Joined: Sun Nov 22, 2009 2:35 pm

Re: very simple mysql question!!!

Post by shou0630 »

oh ye i got it

Code: Select all

$result = mysql_query("SELECT * FROM games
WHERE name IN ('$_GET[search]')");
 
GET works POST doesn't,thanks anyway
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Re: very simple mysql question!!!

Post by morris520 »

depends how you send parameters through the page.
Post Reply