Page 1 of 1

Populate menu grouping results

Posted: Thu Sep 29, 2005 10:00 am
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...

Posted: Fri Sep 30, 2005 8:40 am
by paolone
:roll:

up...

Posted: Fri Sep 30, 2005 9:30 am
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?

Posted: Fri Sep 30, 2005 9:49 am
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...

Posted: Fri Sep 30, 2005 9:54 am
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

Posted: Mon Oct 03, 2005 2:47 am
by paolone
Yes, this seems to be good...
i'll give it a try tomorrow and let you know.
thanks !