473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Print select box according to month days

i want to print a selectbox according to the month date.

1. if month is of 28 days there will show 28 selectbox
2. if month is of 31 days there will show 31 selectbox.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3.     $countDate = date('d');
  4.     $currMonth = date('m');
  5.     $currYear  = date('Y');
  6.     $countDay = days_in_month($currMonth,$currYear);
  7.  
  8.     function days_in_month($month, $year)
  9.     {
  10.     return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
  11.  
  12. } ?>
  13.  
  14. </head>
  15. <body>
  16. <div>
  17.     <table>
  18.         <thead>
  19.             <th>Name</th>
  20.             <?php for($i=1; $i<=$countDay; $i++) {?>
  21.             <th><?php echo $i;?></th>
  22.             <?php } ?>
  23.         </thead>
  24.         <tbody>
  25.        <?php while($row = mysql_fetch_array($query)) {
  26.             echo '
  27.             <td>'.$row['name'].'</td>';} ?>
  28.             <td>
  29.             <?php for ($a=3; $a<25; $a++)    {?>
  30.                     <?php        echo $a;
  31.  
  32.                     ?>
  33.                     <?php    }     ?>
  34.  
  35.                     <?php  $b = "<select>
  36.                            <option>dfkjfdg</option>
  37.                            </select>";
  38.                            for ($c=$b; $c<5; $c++)
  39.                            {
  40.                                echo $c;
  41.                             }
  42.  
  43.                            ?>
  44.  
  45.             </td>
  46.  
  47.         </tbody>
  48.     </table>
  49. </div>
  50. </body>
  51. </html>
  52.  
May 31 '13 #1
2 1418
Oralloy
985 Expert 512MB
sandyyyy35,

What you want to do is straightforward - and I think that I can see a problem with your code.

Still, what are you trying to fix? I'll try to give you pointers.

Regards,
Oralloy
May 31 '13 #2
Luuk
1,047 Expert 1GB
2 comments

Lines 32-33:
Why end your php-section in line 32 '?>', and start a new one in line 33, just to close the previous php-block with a '}'

Lines 35-41:
You assign to $b a selction box, with one element, and then you echo that you output for a couple of times?

or maybe a third comment:
What was your question exactly? It is not clear to /me after reading your post
Jun 1 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Keith W. McCammon | last post by:
So this little problem has stumped me for close to an hour, and I know it's something easy... I'm using PHP to select field values from a record in a MySQL database, and display those values...
2
by: Syl | last post by:
Hi group - I have a table with a date field: eventdate date I need to select all records where the eventdate is 7 days from today. Any ideas ? I've been looking at diffdate but I don't...
1
by: Matt Karp | last post by:
DECLARE @varDate datetime DECLARE @varMonthDate datetime DECLARE @varYear datetime DECLARE @varFOM varchar(10) DECLARE @NumDaysInMonth as int select @varDate = '2/1/2004' select...
9
by: Adam | last post by:
Hey, I'm trying to write a script with two standard drop down boxes. One contains days one contains the month. I want to update the options in the days box everytime the month is changed......
2
by: David Mitchell | last post by:
I have tried using the following code to count the specific number of each weekday but get a compile error "User defined type not defined" which I think relates to the first line of the function: -...
1
by: Steff | last post by:
I am wandering if my code is making sense... I use a lot the print function. Is it weird in this case where I have to display an array ? I thought it would be better to have the entire array in php...
0
by: letsgetsilly | last post by:
Hello all, I'm using MS SQL server. I'm trying to SELECT * FROM 4 different tables WHERE (DueDate < Today'sDate), and therefore overdue. I would like to display all of this information in a...
8
by: Richard | last post by:
I wish to have a month select and next to it a day select. Is there no way at all for the day field to pick up the selected month without a previous submit on the part of the user?
0
by: Garg | last post by:
Hi, I want to hide the rows that show days of other months in my calendar. I want my calendar to show only current month's days. The rows that appear at the bottom or top sometimes, having other...
10
by: YvesDM | last post by:
Hi, How can I do this, I've got a little form with a dropdown. <select name="maand"> <option value='1'>januari</option> <option value='2'>februari</option> <option value='3'>maart</option>...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.