簡體   English   中英

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>&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;

編輯:通過移動我的變量來解決它。 標記為已解決。

我發現了問題。 某些完成輸出的變量位置不好。 重新排列它們,現在它們很好。

您的HTML已損壞,奇怪的事情發生在損壞的表中。 $tableformat包含打開<div><table> HTML,但是在表仍處於打開狀態時關閉<div>

修復損壞的HTML,您可能會發現一切都很好

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM