Willi W Willi W - 3 months ago 24
MySQL Question

Inserting week number in phpmyadmin database when submitting form based on current date

I want to upload current week number in the database without showing it anywhere in the site when users submit a form. Although I do want to use the week number later to show "Winners of week XX" (main reason I want it uploaded to database). At this time I have created a form which does not refresh the page when submitted to the database. In phpmyadmin I have created a field called Week with type INT. If needed I can of course change this according to working code suggestions. I have spent the last 2 days searching the web and trying to make this work, but finally I decided to join the community and ask about it here. Any suggestions?

Do tell if anyone need me to specify some code. At this time I'm working with script in the index.html and PHP in a separate file.

Problem solved: $weekNumber = date("W"); worked like a charm.

Answer

You can get week number by php function date as below and can insert it in DB as per your requirement.

$weekNumber = date("W");