Beo
Three Magic
- Joined
- Aug 25, 2009
- Messages
- 9,053
- Solutions
- 1
- Reaction score
- 844
Having issues with pulling data from 2 columns. It's been a while since I've touched PHP so I thought I'd ask here!
What I need to achieve:
Table A has 2 columns, attr_type and city.
I need to display, where attr_type = 'acc' and city variable, then display based on city.
For example, I click on CityA and it will display any information with the field column CityA
so, if i click on Venore page, it will show any data with the attr_type acc and the city venore.
if I click Thais page, it will show any data with the attr_type acc and the city thais.
sounds easy right?
here comes the catch
I can add city pages as many as I want, with a different page, with different names, so if I was to add Edron through my "add city" page, I need the SQL statement to automatically search Edron, too, without adding it manually as a OR statement. If that makes sense?
Good god, I've butchered my explanation!
Anyway, this is the SQL code I have
but I need to change the city_name to a variable... thanks!
What I need to achieve:
Table A has 2 columns, attr_type and city.
I need to display, where attr_type = 'acc' and city variable, then display based on city.
For example, I click on CityA and it will display any information with the field column CityA
attr_type | city |
acc | thais |
acc | venore |
so, if i click on Venore page, it will show any data with the attr_type acc and the city venore.
if I click Thais page, it will show any data with the attr_type acc and the city thais.
sounds easy right?
here comes the catch
I can add city pages as many as I want, with a different page, with different names, so if I was to add Edron through my "add city" page, I need the SQL statement to automatically search Edron, too, without adding it manually as a OR statement. If that makes sense?
Good god, I've butchered my explanation!
Anyway, this is the SQL code I have
SQL:
$result = mysqli_query($con,"SELECT * FROM table WHERE attr_type = 'ACC' AND city_name = 'THAIS');
but I need to change the city_name to a variable... thanks!