gpt4 book ai didi

php - 记录集中的第一条记录为空。为什么?

转载 作者:行者123 更新时间:2023-12-01 00:14:25 25 4
gpt4 key购买 nike

为什么第一条记录是空的?它不是空的,第一条记录变成第二条记录,第一条记录是空的,它突然出现

这是代码

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com