select * from database WHERE %s = %s
Posted: Mon Sep 06, 2010 7:12 pm
I'm trying to create a master / detail page using some preset search links on the master page to pull from a mySQL database for the detail page.
ie. Marbles, Red.
So, if someone clicks on the Marbles link on the master page I would like the SQL statement to be:
Select * from database WHERE 'type' = marbles.
Or if someone clicks on the Red link, I would like the SQL statement to be:
Select * from database WHERE 'color' = red.
The trick is I'm only using a single detail page. So I would like to use variables for the WHERE statement.
I've tried many different combinations and looked thru the PHP manual and on the web but cannot seem to figure this out.
This is my current statement:
Code:
$query_mini = sprintf("SELECT * FROM database WHERE %s = %s", GetSQLValueString($vid, "text"), GetSQLValueString($mid, "text"));
I'm trying to connect to the page via page.php?vid=type&mid=marble
Or trying to connect to the page via page.php?vid=color&mid=red
I've verified the table names and field names match exactly.
I've setup an echo statement to verify the GET Statements are pulling the URL parameters correctly.
Please help.
Thanks,
Steve
ie. Marbles, Red.
So, if someone clicks on the Marbles link on the master page I would like the SQL statement to be:
Select * from database WHERE 'type' = marbles.
Or if someone clicks on the Red link, I would like the SQL statement to be:
Select * from database WHERE 'color' = red.
The trick is I'm only using a single detail page. So I would like to use variables for the WHERE statement.
I've tried many different combinations and looked thru the PHP manual and on the web but cannot seem to figure this out.
This is my current statement:
Code:
$query_mini = sprintf("SELECT * FROM database WHERE %s = %s", GetSQLValueString($vid, "text"), GetSQLValueString($mid, "text"));
I'm trying to connect to the page via page.php?vid=type&mid=marble
Or trying to connect to the page via page.php?vid=color&mid=red
I've verified the table names and field names match exactly.
I've setup an echo statement to verify the GET Statements are pulling the URL parameters correctly.
Please help.
Thanks,
Steve