gpt4 book ai didi

php - fetch_assoc 不显示第一行结果

转载 作者:行者123 更新时间:2023-11-29 22:10:09 26 4
gpt4 key购买 nike

不知道我做错了什么。我知道有两个 fetch_assoc 会删除第一个结果,但我没有这样的东西。

$sql = "$getdb
WHERE $tablenames.$pricename LIKE 'm9%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo $tableformat;
while($row = $result->fetch_assoc()) {
$name = str_replace('m9', 'M9 Bayonet', $row['Name']);
include 'filename.php';
echo $dbtable;
}

我的连接文件:

$servername = "";
$username = "";
$dbname = "";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

require_once ('seo.php');
$dollar = '2.';
$euro = '1.9';
$tableformat = "<div class=\"CSSTableGenerator style=\"width:600px;height:150px;\"><table><tr><th>Name</th><th>Price</th><th><a class=\"tooltips\">Community<span>New !</span></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Cash Price</th><th>Trend&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Picture&nbsp;&nbsp;&nbsp;</th></tr></div>";
$getdb = "SELECT utf.id, utf.PriceMin, utf.PriceMax, utf.Name, utf.Trend , community1s.price as com_price, utf.Name, utf.Trend
FROM utf
INNER JOIN (select id, avg(price) price from community1 group by id) as community1s
ON utf.id=community1s.id";
$tablenames = 'utf';
$pricename = 'Name';
$idrange = range(300,380);

发生的情况是,它获取前两列的内容,而该行的其余部分不存在,并将其他结果插入一行,这会弄乱数据。

这里有一张图片来演示: http://imgur.com/CQdnycW

seo.php 文件只是一个 SEO 功能。

对于可能导致此问题的原因有什么想法吗?

编辑:

我的输出:

echo $tableformat;
while($row = $result->fetch_assoc()) {
$name = str_replace('m9', 'M9 Bayonet', $row['Name']);
include 'filename.php';
echo $dbtable;

编辑:通过移动我的变量来解决它。标记为已解决。

最佳答案

我发现了这个问题。一些执行输出的变量位置不好。重新排列它们,现在它们很好了。

关于php - fetch_assoc 不显示第一行结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31758100/

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