Results 1 to 11 of 11
Thread: Query from PHP code
Nov 8, 2012, 08:49 #1
- Join Date
- May 2011
- 1 Post(s)
- 0 Thread(s)
Query from PHP code
We are developing a commercial website using PHP and MySQL. We have different kind of customers, and we have created tables for each kind.
We have also developed an administrative area for reviewing the purchases and customers information.
We select the kind of customers we want to check in the first page of the administrative area.
Here some examples of tables and variables involved:
- In the first page the kind of customer is selected from a combo box, and passed to the next page as a post variable
- Customers tables have names like:
So, depending which customer is selected in the first page, the query will involve a different table, for instance:
$SQL = "SELECT Customer_Name FROM Customers_Kind1"
$SQL = "SELECT Customer_Name FROM Customers_Kind2"
In order to have just one generic query to the database, could you please let me know the correct syntaxis to concatenate strings using PHP, and use the post variable with the selected customer to create the SQL query?
Something like this:
$SQL = "SELECT Customer_Name FROM Customers_".$POST['selected_customer']
Thanks a lot!!