Local Hero
04-24-2009, 06:00 PM
Lets say I have a table with 1 column having a list of months:
Jan, Jan, Feb, Jan, Feb, Feb, Jan, Feb
And another column having a list of dates associated with those months:
1,2,5,7,14,12,30,16
I want to view the results like this:
Jan
1
2
7
30
Feb
5
14
12
16
Here is what I'm working with:
<?php
$sql="SELECT month, day FROM calendar GROUP BY month";
$sql2="SELECT month, day FROM calendar ORDER BY month";
$result=mysql_query($sql);
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result)){
?>
<table><tr><td>
<?php echo( $rows['month'] ); ?>
</td></tr><tr><td>
<?php
while($rows2=mysql_fetch_array($result2)){
echo $rows2['day'] ;?>
}
?>
</td></tr></table>
<?php
}
?>
I'm getting 2 tables - Jan & Feb, but all the dates go in Jan. I can see why it's doing that. I can't figure out how to get the Feb dates over in the Feb table. Thanks for any suggestions or direction.
Jan, Jan, Feb, Jan, Feb, Feb, Jan, Feb
And another column having a list of dates associated with those months:
1,2,5,7,14,12,30,16
I want to view the results like this:
Jan
1
2
7
30
Feb
5
14
12
16
Here is what I'm working with:
<?php
$sql="SELECT month, day FROM calendar GROUP BY month";
$sql2="SELECT month, day FROM calendar ORDER BY month";
$result=mysql_query($sql);
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result)){
?>
<table><tr><td>
<?php echo( $rows['month'] ); ?>
</td></tr><tr><td>
<?php
while($rows2=mysql_fetch_array($result2)){
echo $rows2['day'] ;?>
}
?>
</td></tr></table>
<?php
}
?>
I'm getting 2 tables - Jan & Feb, but all the dates go in Jan. I can see why it's doing that. I can't figure out how to get the Feb dates over in the Feb table. Thanks for any suggestions or direction.