Jump to content

Database Query and URL Parameters


mlotis

Recommended Posts

So I'm creating a website for bar deals... I've tried for hours trying to get the url to take in more than one parameter with no luck, I don't know if my database isn't setup correctly or something but the url would look like this

 

http://www.site.com/?id=1&day=Monday

 

and when those parameters are passed the deals for that id and day are then posted in the content area

 

I'm pretty much stumped. I feel like it's much easier than I am making it.

 

My database looks like:

 

ID  Name  Monday          Tuesday        Wednesday -> and so on

 

1    Bar1  MondayDeal TuesdayDeal WednesdayDeal

2    Bar2  MondayDeal -> and so on

Link to comment
Share on other sites

let's assume the table is called "bar_table" (you didn't say)

 

This should do it:

$query = mysql_query("SELECT ". $_GET['day'] . " FROM bar_table WHERE id='".$_GET['id']."'");

Seems to be what your looking for. of course I'd be more secure with the query but thats the basic idea.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.