Print select box according to month days

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sandyyyy35
    New Member
    • May 2013
    • 21

    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.

    Code:
    <?php 
    session_start();
    	$countDate = date('d');
    	$currMonth = date('m');
    	$currYear  = date('Y');
    	$countDay = days_in_month($currMonth,$currYear);
    
    	function days_in_month($month, $year)
    	{
    	return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
    	
    } ?>
    
    </head>
    <body>
    <div>
    	<table>
        	<thead>
    			<th>Name</th>
    			<?php for($i=1; $i<=$countDay; $i++) {?>
            	<th><?php echo $i;?></th>
                <?php } ?>
            </thead>
            <tbody>
           <?php while($row = mysql_fetch_array($query)) {
    			echo '
            	<td>'.$row['name'].'</td>';} ?>
                <td>
                <?php for ($a=3; $a<25; $a++)	{?>
    					<?php		echo $a;
    							
    					?>
    					<?php	}	 ?>
                        
                        <?php  $b = "<select>
    						   <option>dfkjfdg</option>
    						   </select>";
    						   for ($c=$b; $c<5; $c++)
    						   {
    							   echo $c;
    							}
    						   
    						   ?>
                
                </td>
    			
            </tbody>
        </table>
    </div>
    </body>
    </html>
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    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

    Comment

    • Luuk
      Recognized Expert Top Contributor
      • Mar 2012
      • 1043

      #3
      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

      Comment

      Working...