可能重复:
how to show multiple news in marquee from mysql using php
我想知道如何在表之间的选框中回显多个新闻,我只能回显一个新闻,我想在表格内的主页中使用选框查看4个以上的新闻,新闻已经发布在数据库中。我正在使用此代码:
<?php
include("connect.php");
$select="SELECT newsid, headlines from news WHERE uploaddate order by uploaddate desc limit 4";
$rsd=mysql_query($select);
while($row = mysql_fetch_array($rsd))
{
$newsid=$row['newsid'];
$tittle=$row['headlines'];
}
?>
在设计中我正在使用此代码
<table >
<tr>
<td width="87%">
<marquee style="color: #FF0000; font-family: Verdana; font-variant: small-caps; font-size: 10pt; font-weight: bold" scrollAmount="2" scrollDelay="20" width="840" bgColor="#CCCCFF" height="24">
<?php echo $tittle; ?></marquee></td>
</tr>
</table>
答案 0 :(得分:0)
问题在于你的循环......
执行此操作的部分:
<?php echo $tittle; ?>
//should be in the loop like below:
<!--starting from the above the loop-->
<table>
<?php
while($row = mysql_fetch_array($rsd)){
$tittle = $row['headlines'];
echo '<tr><td>';
echo '<marquee style="color:#ff0000; .......>';
echo $tittle;
echo '</marquee>';
echo '</td></tr>';
}
?>
</table>
希望这能帮到你!
答案 1 :(得分:0)
<marquee >
<table>
<?php
$sql="SELECT newsid,headlines FROM `news` ORDER BY uploaddate DESC LIMIT 4 ";
$res=func_query($sql);
foreach($res as $key=>$val)
{
?>
<tr><td><?=$val['headlines']?>: </h5></td></td>
<tr><td><hr style="border: 1px dotted #B8B8B8;"/></td></tr>
<?php
}
?>
</table>
</marquee>