/    Sign up×
Community /Pin to ProfileBookmark

Php and Mysql question help!

I am using this query below to search data from a table called messages where the date is nov.

$query=”SELECT * FROM messages WHERE date LIKE ‘nov%’ ORDER BY id DESC”;

I want the user to be able to choose the month he/she wants to veiw messages from using links such as November | December | January | etc…

$query=”SELECT * FROM messages WHERE date LIKE ‘$month%’ ORDER BY id DESC”;
Is this the correct query and if so how should i set up the variables and the links?
I was using this…
$month = $_get[‘month’]
and the Link was
<a href=”http://www.url.com/messages/index.php?month=november“>
But it didnt work. Im kinda confused as you can tell…

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@bokehNov 23.2005 — Date is a reserved word in MySQL. Try using backticks.
[code=php]$query="SELECT * FROM messages WHERE date LIKE 'nov%' ORDER BY id DESC";[/code]
×

Success!

Help @ernielaverdi 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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