/    Sign up×
Community /Pin to ProfileBookmark

Question about URL query string

Hi

Suppose I have a URL

[url]http://www.mysite.com/products.php?cat=software&id=2[/url]

What should I do such that when I click on this link, the parameters cat=software and id=2 are passed as part of a query to a database manager (say MySQL) so that the database manager knows that I’m asking for:

Select * from DB where cat=’software’ and id=’2′

so that it will process the query and return the results for display? I’ve read about mod_rewrite and url query string but haven’t quite figured out. Any idea?

to post a comment
Full-stack Developer

1 Comments(s)

Copy linkTweet thisAlerts:
@ray326Dec 23.2007 — It doesn't go "directly" to the database. You process the information in a "form handler", which may as part of its function interact with a database manager. You also never literally paste the incoming field content directly into a SQL statement without rigorous validation beforehand.

Read up on model-view-controller. In this simple example the form is the view, the form handler is the controller and the back end database is the model.
×

Success!

Help @trivektor 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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