Home  >  Article  >  Backend Development  >  请全能大神解答,此功能用PHP怎么写?JSP代码已有,求翻译或者思路!路过请看看!

请全能大神解答,此功能用PHP怎么写?JSP代码已有,求翻译或者思路!路过请看看!

WBOY
WBOYOriginal
2016-06-23 13:23:58794browse

就是判断mysql的内容,在HTML上控制输出的颜色,具体请看下面:

链接: http://zhidao.baidu.com/link?url=rd4D37D5SxFe8fiQiJjEToUtziRhaQmYlo9QckfgBbgTHO8kXnchNhHh66N1gr7wFVdAa_Jyh-tvZCrvyUC5hq

这个需求百度上已有解答,但是是用PHP写的,有哪位高手能翻译成PHP么?或者有自己的思路?


回复讨论(解决方案)

<?php$conn = mysql_connect('localhost', 'root', '');mysql_select_db('test', $conn);$sql="select * from test";$r = mysql_query($sql);?>  <table><tr bgcolor=green><th>id</th><th>name</th><th>ifpass</th></tr>  <?php  while($rs = mysql_fetch_assoc($r))  {   if($rs["ifpass"] == "y")   {    echo ("<tr bgcolor=blue>");   }else{    echo ("<tr bgcolor=red>");   }?>   <td> <?php echo $rs["id"];?> </td>   <td> <?php echo $rs["name"];?> </td>   <td> <?php echo $rs["ifpass"];?> </td>   </tr>   <?php  }echo ("</table>");?>

さすが管理者さんです!お?事!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn