SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: selected Month

  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,096
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    selected Month

    Hi,

    I have new problem and i need some help with you guys.why i could not display the month to be selected.

    this is my code
    Code:
    <select name="month">
    				   <option value=""></option>
    					<option value="1"
    					 <?php
    					    if($month==1)
    						 {echo 'selected="selected"';}
    					 ?>
    					>January</option>
    					<option value="2"
    					<?php
    					    if ($month==2)
    						 {echo 'selected="selected"';}
    					 ?>
    					
    					>February</option>
    					<option value="3"
    					<?php
    					    if ($month==3)
    						 {echo 'selected="selected"';}
    					 ?>
    					>March</option>
    					<option value="4"
    					<?php
    					    if ($month==4)
    						 {echo 'selected="selected"';}
    					 ?>
    					>April</option>
    					<option value="5"
    					<?php
    					    if ($month==5)
    						 {echo 'selected="selected"';}
    					 ?>
    					
    					>May</option>
    					<option value="6"
    					<?php
    					    if ($month==6)
    						 {echo 'selected="selected"';}
    					 ?>
    					
    					>June</option>
    					
                                           .......
                                           ......
                                     </select>
    This is how i select the table.

    Code:
     if(isset($_GET['idno']))
       {
             $idno = $_GET['idno'];
    	 $dosel="SELECT * from MYtable where ID = $idno";
    	 
    	 $res = mysql_query($dosel);
    	
    	
    	   while($row = mysql_fetch_array($res))
    	    {
    		  $idno = $row["ID"];
    		  ......
                      ........
                      ........
    		  $month=date('F',strtotime($row["BIRTH"]));
    		  
    	   }
      }

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    date('F', ...) means that the value of month will not be 1, 2, 3 etc. It will be "January", "Feburary" etc.

    You can either change date('F', ... ) to date('n', ... ), or change your if statements.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,096
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jake Arkinstall View Post
    date('F', ...) means that the value of month will not be 1, 2, 3 etc. It will be "January", "Feburary" etc.

    You can either change date('F', ... ) to date('n', ... ), or change your if statements.


    Hi,Thank you for the reply...okay i will try this one.

  4. #4
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,096
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jake Arkinstall View Post
    date('F', ...) means that the value of month will not be 1, 2, 3 etc. It will be "January", "Feburary" etc.

    You can either change date('F', ... ) to date('n', ... ), or change your if statements.

    Hi it's working...thank you so much.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •