hammerslane
10-13-2003, 05:07 AM
hello people, before i begin explaining my problem, i'll just say that i've only been doing php+mysql stuff together for a few weeks, so still not quite sure how sql queries operate, and how much they directly tie together with php.
i have two pages, 1.php and 2.php. you start at 1.php, and select a company from a form list. submit then sends through a variable to 2.php with the company name (in this case, the address will be "http://www.lovelydatabase.com/2.php?company=$barclays_bank").
2.php should basically just go into the database and get all the contact information for the bank.
this is record in the database that it should display the information for. the variable_id is just an identifier for the sql query to use, to compare the sql field to the browser variable.
company barclays_bank
email blokey@blokeys-bank.com
phone 5095 8427
address 1 High Street etc
variable_id barclays_bank
this is the sql query which is trying to say "where the browser variable on this page is the same as the variable_id in a record, display that row." - because i only want to display the record which is relevant to the option selected on 1.php, there are about 40 more records in the table which are uniquely identified by the variable_id entity.
SELECT *
FROM contactinformation
WHERE companyname=$barclays_bank
i've tried this and it doesn't work (as you probably know), should php variables work in sql queries? is there a way to do what i'm trying to do?
my novice experience says that the "WHERE companyname=$barclays_bank" line has to be phrased differently... i have no idea how though.
i have tried to explain this as best i can, if you need to know any information vital to understanding my problem, please ask, and if you can't understand it, let me know and i'll re type the problem.
thanks people :cool:
i have two pages, 1.php and 2.php. you start at 1.php, and select a company from a form list. submit then sends through a variable to 2.php with the company name (in this case, the address will be "http://www.lovelydatabase.com/2.php?company=$barclays_bank").
2.php should basically just go into the database and get all the contact information for the bank.
this is record in the database that it should display the information for. the variable_id is just an identifier for the sql query to use, to compare the sql field to the browser variable.
company barclays_bank
email blokey@blokeys-bank.com
phone 5095 8427
address 1 High Street etc
variable_id barclays_bank
this is the sql query which is trying to say "where the browser variable on this page is the same as the variable_id in a record, display that row." - because i only want to display the record which is relevant to the option selected on 1.php, there are about 40 more records in the table which are uniquely identified by the variable_id entity.
SELECT *
FROM contactinformation
WHERE companyname=$barclays_bank
i've tried this and it doesn't work (as you probably know), should php variables work in sql queries? is there a way to do what i'm trying to do?
my novice experience says that the "WHERE companyname=$barclays_bank" line has to be phrased differently... i have no idea how though.
i have tried to explain this as best i can, if you need to know any information vital to understanding my problem, please ask, and if you can't understand it, let me know and i'll re type the problem.
thanks people :cool: