Php 我的动态表不断重复每个新数据库条目的标题
我试图使用Dreamweaver cs5中的重复区域创建动态表,但不幸的是,在浏览器上查看时,每个新记录条目也会重复标题Php 我的动态表不断重复每个新数据库条目的标题,php,html,mysql,content-management-system,dreamweaver,Php,Html,Mysql,Content Management System,Dreamweaver,我试图使用Dreamweaver cs5中的重复区域创建动态表,但不幸的是,在浏览器上查看时,每个新记录条目也会重复标题 公司参考日期 海布里223333 2014-02-01 公司参考日期 安菲尔德223335 2014-02-03 公司参考日期 特拉福德223336 2014-02-02 如何使表格仅显示标题一次,并在其下方显示相应条目? i、 e 公司参考日期 海布里223333 2014-02-01 安菲尔德223334 2014-02-03 特拉福德223336 2014-02-
- 公司参考日期 海布里223333 2014-02-01 公司参考日期 安菲尔德223335 2014-02-03 公司参考日期 特拉福德223336 2014-02-02
- 公司参考日期 海布里223333 2014-02-01 安菲尔德223334 2014-02-03 特拉福德223336 2014-02-02
<?php require_once('Connections/connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connect, $connect);
$query_field = "SELECT * FROM field";
$field = mysql_query($query_field, $connect) or die(mysql_error());
$row_field = mysql_fetch_assoc($field);
$totalRows_field = mysql_num_rows($field);
?>
<?php do { ?>
<table class="table table-hover table-nomargin">
<thead>
<tr>
<th>Company</th>
<th>Ref No.</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $row_field['i_company']; ?></td>
<td><?php echo $row_field['i_ref']; ?></td>
<td><?php echo $row_field['i_date']; ?></td>
</tr>
</tbody>
</table>
<?php } while ($row_field = mysql_fetch_assoc($field)); ?>
您需要将do while语句移到表记录中
<table class="table table-hover table-nomargin">
<thead>
<tr>
<th>Company</th>
<th>Ref No.</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php do { ?>
<tr>
<td><?php echo $row_field['i_company']; ?></td>
<td><?php echo $row_field['i_ref']; ?></td>
<td><?php echo $row_field['i_date']; ?></td>
</tr>
<?php } while ($row_field = mysql_fetch_assoc($field)); ?>
</tbody>
</table>
单位
参考号。
日期
您的Do/While函数告诉第一行在数据库中找到的每一行都要运行标题。尝试将Do/While函数包装在仅包含变量的行上,如下所示:
<table class="table table-hover table-nomargin">
<thead>
<tr>
<th>Company</th>
<th>Ref No.</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php do { ?>
<tr>
<td><?php echo $row_field['i_company']; ?></td>
<td><?php echo $row_field['i_ref']; ?></td>
<td><?php echo $row_field['i_date']; ?></td>
</tr>
<?php } while ($row_field = mysql_fetch_assoc($field)); ?>
</tbody>
</table>
单位
参考号。
日期
这样,它只会在该行重复,而不会复制标题。为什么取消选中我的答案?对不起,伙计1。。。我可能是无意中这样做的,因为我认为你可以“检查”所有正确的答案!。。。再一次,对不起!