Populate menu grouping results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Populate menu grouping results

Post by paolone »

Hello !

I have a drop down menu populated from a MySQL results.

Right now it shows the date of the day that can be choosen. So the date appear if it is in the database.

now i'd like to have a drop down menu, not the same one, but in another page.
This will show the week to choose and when submitted will send values to a query...

I mean, right now i did it manually like this :

Code: Select all

<select name="period">
		  <option value="`theDate` >= '2005-08-01' AND `theDate` <= '2005-08-05'">01 - 05 aug 2005</option>
		  <option value="`theDate` >= '2005-08-08' AND `theDate` <= '2005-08-12'">08 - 12 aug 2005</option>
		  <option value="`theDate` >= '2005-08-15' AND `theDate` <= '2005-08-19'">15 - 19 aug 2005</option>
		  <option value="`theDate` >= '2005-08-22' AND `theDate` <= '2005-08-26'">22 - 26 aug 2005</option>
		  <option value="`theDate` >= '2005-08-29' AND `theDate` <= '2005-09-02'">29 aug - 02 sept 2005</option>
		  <option value="`theDate` >= '2005-09-05' AND `theDate` <= '2005-09-09'">05 - 09 sep 2005</option>
		  <option value="`theDate` >= '2005-09-05' AND `theDate` <= '2005-09-09'">05 - 09 sep 2005</option>
          <option value="`theDate` >= '2005-09-12' AND `theDate` <= '2005-09-16'">12 - 16 sep 2005</option>
          <option value="`theDate` >= '2005-09-19' AND `theDate` <= '2005-09-23'" selected>19 - 23 sep 2005</option>
        </select>
can i build the same, but dinamically from the Database? right now i should add every monday the menu items for the week before... :?

thanks all...
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

:roll:

up...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

your question does not make any sence to me. what exactally is it that you want to do? what is wrong with what you have there?
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

Ok, thanks...

here i go better. the one aboove is a drop down menu that i have filled maually taking the days and putting them together to give a week (as you see for instance "19 - 23 sep 2005"). this one will send to the database query the value "`theDate` >= '2005-09-19' AND `theDate` <= '2005-09-23'".

the dates (2005-09-19 and so on...) are coming from a previuos insertion in the database. and are in the date format as shown.

What i would like to do, is that after a week is completed in the database, (from monday to friday), the new menu item is automatically generated...

i think this is more clear... let me know... :)
thanks again...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

-get the current date using the date() function.
-use the date() function to also get the day or the week
-use that information to add and subtract the days from the current date so you will have 7 variables, 1 for each day of the current week

put those variables in the dropdown menu so then you will be good. there might be other ways but that is probably how i would do it
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

Yes, this seems to be good...
i'll give it a try tomorrow and let you know.
thanks !
Post Reply