/    Sign up×
Community /Pin to ProfileBookmark

php / sql query help

Hi, I’ve been working on this website:

[url]http://www.badnutbeats.co.uk/inotherwords[/url]

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.

Cheers

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Skylight_LadyFeb 24.2011 — Did you forget to post your code. You won't get any help without displaying your code.
Copy linkTweet thisAlerts:
@DasherFeb 24.2011 — 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.
Copy linkTweet thisAlerts:
@danz321authorFeb 24.2011 — right, sorry... im so stupid for not adding code! :p

I've worked out that this is almost what I want:


[CODE]$query="Select Distinct original, subject, date FROM phrases WHERE original LIKE '".$alphabet."%' AND subject LIKE '".$subject."%' ORDER BY date DESC";
[/CODE]



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 ?
×

Success!

Help @danz321 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...