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
https://forums.phpfreaks.com/topic/224911-database-query-and-url-parameters/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.