SELECT expression - multiple queries via a single script
Posted: Mon Jun 05, 2006 5:13 pm
This is my first day working with php and mySQL so apologies if I'm missing something obvious. I used to think I could Google, but how do you write a query about writing queries?! There is so much information that not knowing what I'm looking for is the hardest part! Please feel free to direct me at the right guidance - I'm happy to RTFM if I only knew where to begin.
I have set up a table which is basically a list of members with various attributes - some yes/no type fields, a catA,catB,catC field, a URL field and the member name.
I've managed to use php to display a list of members, linked to their websites where they exist and can filter by a single field (memCat) by putting
Ideally, I'd like to complete this php script and use the different fields in the URL, e.g. members.php?memCat=I&memD=D
However, I've come unstuck on two different questions.
1) How do I make it show all records? leaving memCat= out of the URL doesn't work and I've looked at wildcards but can't figure them out - I've tried _ and % but must be missing something
2) How do I make it only filter by those fields listed in the URL (e.g. if the URL is members.php?memD=D how do I make it show all records that have memD=D no matter what the value of memCat is?
Thanks for any help you can give me!
Adam
I have set up a table which is basically a list of members with various attributes - some yes/no type fields, a catA,catB,catC field, a URL field and the member name.
I've managed to use php to display a list of members, linked to their websites where they exist and can filter by a single field (memCat) by putting
Code: Select all
$query="SELECT * FROM Members WHERE memCat='$memCat' ORDER BY memName ASC";However, I've come unstuck on two different questions.
1) How do I make it show all records? leaving memCat= out of the URL doesn't work and I've looked at wildcards but can't figure them out - I've tried _ and % but must be missing something
2) How do I make it only filter by those fields listed in the URL (e.g. if the URL is members.php?memD=D how do I make it show all records that have memD=D no matter what the value of memCat is?
Thanks for any help you can give me!
Adam