php / sql query help
Hi, I've been working on this website:
As you can see on the website there are 3 menus. The idea is for one item on each menu to stay highlighted in order to filter down results. So if 'Art', 'A', and 'Most Recent' were highlighted, then the SQL query would get results that have 'art' as their subject and of them, only the results beginning with 'A'. They would then be ordered by date (most recent).
Also, as a lot of the results have duplicate titles, they need to be filtered out to so that there is only ever one instance of each title.
When each button is clicked it's value is added to the URL string and then put into variables ($alphabet, $subject, $listtype)
I know that's quite a lot to ask so I'll just wait in hope. :| I've been trying to work it out all day and got nowhere so any pointer will be good. Someone already mentioned LEFT OUTER JOINing but I wasn't sure how to implement it.
Did you forget to post your code. You won't get any help without displaying your code.
How to implement your query depends on how your data table(s) are constructed. Do you have columns for keywords, titles, subject, content, etc. Different tables for different types of content, etc. That kind of information is needed before a query can be defined. If everything is in one big table there is not need for JOINs since there are no tables to join.
right, sorry... im so stupid for not adding code!
I've worked out that this is almost what I want:
$query="Select Distinct original, subject, date FROM phrases WHERE original LIKE '".$alphabet."%' AND subject LIKE '".$subject."%' ORDER BY date DESC";
That filters down the results like I want it to, however, because I have to select multiple columns from the table, DISTINCT won't work. How do I fix this? I'm clueless :|
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread