Output problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Output problem

Post by John Cartwright »

I'm sorry I made a topic before and I solved it right after, so to not re-post things this is sort of related to the other thing so I'm just putting it here :D

Code: Select all

<?php
$pastmonth = ""; // so that the first month always gets outputted. 

while ($row = mysql_fetch_array($result)) { 
   
	$newdate = explode("-",$row["date"]); 
	$month = $newdate[1]; // eg. February 
    $day = $newdate[2]; // eg. 04 
    $year = $newdate[0]; // eg. 2004 

   if ($month == "01") {
   		$month2="January"; 
   }elseif ($month == "02") { 
   		$month2="Febuary"; 
   }elseif ($month == "03") { 
   		$month2="March"; 
   }elseif ($month == "04") { 
   		$month2="April"; 		
   }elseif ($month == "05") { 
   		$month2="May"; 		
   }elseif ($month == "06") { 
   		$month2="June"; 
   }elseif ($month == "07") { 
   		$month2="July"; 
   }elseif ($month == "08") { 
   		$month2="August"; 
   }elseif ($month == "09") { 
   		$month2="September"; 
   }elseif ($month == "10") { 
   		$month2="October"; 
   }elseif ($month == "11") { 
   		$month2="November"; 
   }else{ 
   		$month2="December"; 
   }

//displaying the releases

   if ($pastmonth != $month) { 
        echo "<br>".$month."<br>" 
		."<table width="688" border="1" cellpadding="0" cellspacing="0" bordercolor="0" bgcolor="E2E2E2">\n";}
      
	  echo "<tr bordercolor="E2E2E2">\n"
    	."<td width="82"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">$day</font></div></td>\n"
    	."<td width="600"><font size="2" face="Arial, Helvetica, sans-serif">".$row["releasedesc"]."</font></td>\n"
  	    ."</tr>\n";
					
		   if ($pastmonth = $month) { 
            echo "</table><br>"; 
			} 				 
							  
 //  echo $day." - ".$row["releasedesc"]."<br>"; 
   $pastmonth = $month; // set the current month to the past month. 
?>
My problem is that the output is doing this

Month
<table> content 1 </table>
content 2
content 3

Month
<table> content 1 </table>
content 2
content 3

Month
<table> content 1 </table>
content 2
content 3

I can't seem to make it table each month's content. Can anyone help?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

change if ($pastmonth = $month) {
to if ($pastmonth == $month) {
Post Reply