![](/img/trans.png)
[英]Why doesn't the rowcount and results show at the same time, when i am using setFetchMode(PDO::FETCH_ASSOC)
[英]fetch_assoc doesn't show first row of results
不知道我做错了什么。 我知道有两个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> </th><th>Cash Price</th><th>Trend </th><th>Picture </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;
编辑:通过移动我的变量来解决它。 标记为已解决。
我发现了问题。 某些完成输出的变量位置不好。 重新排列它们,现在它们很好。
您的HTML已损坏,奇怪的事情发生在损坏的表中。 $tableformat
包含打开<div>
和<table>
HTML,但是在表仍处于打开状态时关闭<div>
。
修复损坏的HTML,您可能会发现一切都很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.