Jump to content

Recommended Posts

I've got some code that works well until I hit Sept listing.

$sql = "SELECT * FROM LPV_boatSchedule ORDER BY syear, smonth, sday";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

     // output data of each row
     while($row = $result->fetch_assoc()) {
$IDENT=$row['ID'];
$SDAY=$row['sday'];
$SYEAR=$row['syear'];
$STIME=$row['stime'];
$SNAME=$row['sname'];
 
	echo "   
	  <tr valign\"top\" bgcolor=\"#FFD2A6\"> 
	   <td width=\"18%\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=2>";
	    if ($row['smonth'] == 01){echo "January";} 
	    if ($row['smonth'] == 02){echo "February";} 
            if ($row['smonth'] == 03){echo "March";} 
	    if ($row['smonth'] == 04){echo "April";} 
	    if ($row['smonth'] == 05){echo "May";} 
	    if ($row['smonth'] == 06){echo "June";} 
	    if ($row['smonth'] == 07){echo "July";} 
	    if ($row['smonth'] == 08){echo "August";} 
	    if ($row['smonth'] == 09){echo "September";} 
	    if ($row['smonth'] == 10){echo "October";} 
	    if ($row['smonth'] == 11){echo "November";} 
	    if ($row['smonth'] == 12){echo "December";} 
	   echo  " $SDAY, $SYEAR</font></td>

Displays all months with their names EXCEPT August & September. Data is correct in the database. This has confounded me for days. Any suggestions as to the cause?

Remove the 0's from the number values. A leading 0 implies octal notation so only digits 0-7 are valid. Hence O8 and O9 are not valid numbers.

 

Use DATE types instead of separate fields, then all that processing can be done simply within the query.

 

You can also use datetime objects to format the date as required with a single line of code.

Edited by Barand
  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.