Forum Moderators: coopster

Message Too Old, No Replies

How to put the articles to appear a day

In only a table

         

romzinho2k7

1:07 am on May 13, 2006 (gmt 0)

10+ Year Member



Hey friends, all right?

I am with a problem not do not manage to solve. It is a little complicated of explain, because of this I put two image. One as it is staying and another how I wanted stayed.

As it is staying:
<day title repeats for every article>

As that wanted stayed:
<day title only once with articles grouped underneath>

In other words, it wanted all the day article X stayed with only a title, and not so that each day generated a different day. Below it follows script that I am using:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<?php
$query = mysql_query("SELECT * FROM articles") or die(mysql_error());
while($f = mysql_fetch_array($query)){
$id = $f["id"];
$day = $f["day"];
$title = $f["title"];
?>
<table width="482" border="0" cellspacing="3" cellpadding="0">
<tr>
<td>&nbsp;&nbsp;Day: <?=$day;?></td>
</tr>
</table>

<table width="482" border="0" cellspacing="3" cellpadding="0">
<tr>
<td width="21" align="center"><input type="checkbox" name="checkbox" value="checkbox" /></td>
<td width="255"><?=$title;?></td>
</tr>
</table>
<?php
}
?>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Sorry my bad English.

Please Help me

Thanks

[edited by: jatar_k at 2:54 pm (utc) on May 15, 2006]
[edit reason] removed links [/edit]

jatar_k

2:57 pm on May 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can use a comparison to the last day then do

if next day!= last day echo title

or in code

<?php
$query = mysql_query("SELECT * FROM articles") or die(mysql_error());
$lastday = '';
while($f = mysql_fetch_array($query)){
$id = $f["id"];
$day = $f["day"];
$title = $f["title"];

if ($day!= $lastday) {
?>
<table width="482" border="0" cellspacing="3" cellpadding="0">
<tr>
<td>&nbsp;&nbsp;Day: <?=$day;?></td>
</tr>
</table>
<? }?>

<table width="482" border="0" cellspacing="3" cellpadding="0">
<tr>
<td width="21" align="center"><input type="checkbox" name="checkbox" value="checkbox" /></td>
<td width="255"><?=$title;?></td>
</tr>
</table>
<?php
$lastday = $day;
}
?>

something like that