Home  >  Article  >  Backend Development  >  怎么将数据库查询的记录集 赋值给表格

怎么将数据库查询的记录集 赋值给表格

WBOY
WBOYOriginal
2016-06-13 11:54:181237browse

如何将数据库查询的记录集 赋值给表格
查询数据库,并返回记录集,但该如何将返回的记录集在表格进行显示?html、php、javascript实现都行,最好说的详细点,有示例代码。

------解决方案--------------------

<table border="1" width="100%" ><br />		<tr><br />			<td>姓名</td><br />			<td>性别</td><br />			<td>身份证</td><br />			<td>收货地址</td><br />			<td>联系电话</td><br />			<td>希望额度</td><br />			<td>申请银行</td><br />			<td>申请时间</td><br />			<td>删除本行</td><br />		</tr><br />			 <?php<br /> <br />                       while($row=mysql_fetch_array($result)) <br />						 { <br />				?><br />                       <tr><br />					<td><?php echo $row['name'] ?></td><br />					<td><?php echo $row['sex'] ?></td><br />					<td><?php echo $row['idNum'] ?></td><br />					<td><?php echo $row['address'] ?></td><br />					<td><?php echo $row['phone'] ?></td><br />					<td><?php echo $row['erdu'] ?></td><br />					<td><?php echo $row['yinhang'] ?></td><br />					<td><?php echo $row['date'] ?></td><br />					<td><a href="javascript:if(confirm('确实要删除该行吗?'))location='delete.php?name=<?php echo $row['name'] ?>'">删除</a></td><br />		                </tr><br />				<?php<br />						   <br />						 }<br />	<br />			 ?>

------解决方案--------------------

引用:
如果我把表格事先建好了呢,跟据条件不同,查询结果动态赋值到表格,表格有部分单元格没有查询到的数据,还得需要给这些单元格赋值为,这样改怎么做?

加个判断就行了$row['idNum'] =  empty($row['idNum'])) ? "00.0000" : $row['idNum'] ;
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