为什么第一条记录是空的?它不是空的,第一条记录变成第二条记录,第一条记录是空的,它突然出现
这是代码
mysql_select_db($database_webiceberg, $webiceberg);
$query_services = "SELECT
services.dynamic_price,
services.database_price
from services
where lang=2 " ;
$services = mysql_query($query_services, $webiceberg) or die(mysql_error());
这部分代码在正文中
<?php do {
$title = $row_services['dynamic_price'];
$database_price = $row_services['database_price'];
$id = $row_services['id_services'];
?>
<tr id="<?php echo $id;?>">
<td class="matrixItem" >
<a href="WebDesign.php?cattegory=<?php echo $cattegory; ?>" id="nigga"><?php echo $title; ?></a>
</td>
</tr>
<?php } while ($row_services = mysql_fetch_assoc($services));
?>
我删除了其中的部分代码以提供更多语法,因为我删除的代码是多余的
最佳答案
do{}
block 将在 while()
之前运行,因此 $row_services
首先为 null。
使用简单的 while 或在 do
之前写 $row_services = mysql_fetch_assoc($services)
<?php
while ($row_services = mysql_fetch_assoc($services)):
$title = $row_services['dynamic_price'];
$database_price = $row_services['database_price'];
$id = $row_services['id_services'];
?>
<tr id="<?php echo $id;?>">
<td class="matrixItem" >
<a href="WebDesign.php?cattegory=<?php echo $cattegory; ?>" id="nigga"><?php echo $title; ?></a>
</td>
</tr>
<?php endwhile; ?>
关于php - 记录集中的第一条记录为空。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8195444/