Results 1 to 4 of 4

Thread: php / sql query help

  1. #1
    Join Date
    May 2005

    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.


  2. #2
    Join Date
    Feb 2011
    Did you forget to post your code. You won't get any help without displaying your code.

  3. #3
    Join Date
    Jan 2006
    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.

  4. #4
    Join Date
    May 2005
    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 :|

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center