日期:2014-05-17  浏览次数:20407 次

跑马灯中信息显示的问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
body{
margin:0px;
padding:0px;
text-align:center;
}
#right{
margin:0px auto;
padding:0px;
text-align:center;
}
ul,li{
margin:0px;
padding:0px;
}
#right li{
list-style:none;
}
</style>
</head>
<body>
<?php
include_once("conn.php") ;
$show_sql="select username ,telephone from enlist_table order by enlist_id desc limit 10" ;
$show_mysql=mysql_query($show_sql) or die("Could not query".mysql_error()) ;
$show_info=mysql_fetch_array($show_mysql) ;
function fun($str){
$tmpstr="" ;
if(ord(substr($str ,0 ,1))>0xa0){
$tmpstr.=substr($str ,0 ,2) ;
}
else{
$tmpstr.=substr($str ,0 ,1) ;
}
return $tmpstr ;
}
do{
//var_dump($show_info["telephone"]) ;
$name=fun($show_info["username"]) ;
$html_info="<ul>" ;
$html_info .="<li>".$name."***&nbsp;&nbsp;".substr($show_info["telephone"] ,0 ,7)."****</li>" ;
$html_info .="</ul>" ;
}while($show_info=mysql_fetch_array($show_mysql)) ;
?>
<div id="right">
<marquee behavior=scroll direction=up align=middle border=1 width=440 height=230 id="logo" onmouseout="logo.start()" onmouseover="logo.stop()">
<?php
echo $html_info;
?>
</marquee>
</div>
</div>
</body>
</html>
<?php
mysql_close() ;
?>
页面运行的时候,应该会有几条信息在跑动,用var_dump()函数进行输出,会有几条结果,但是跑灯的时候,怎么就只有一条呀!急,谢谢。
------解决方案--------------------
这样试试
do{
$html_info="<ul>" ;
//var_dump($show_info["telephone"]) ;
$name=fun($show_info["username"]) ;
$html_info .="<li>".$name."***&nbsp;&nbsp;".substr($show_info["telephone"] ,0 ,7)."****</li>" ;
}while($show_info=mysql_fetch_array($show_mysql)) ;
$html_info .="</ul>" ;