gpt4 book ai didi

html - 使用 mysql 查询生成大型 html 表非常慢 - 4000+ 行查询

转载 作者:行者123 更新时间:2023-11-30 00:47:49 26 4
gpt4 key购买 nike

该表是在我发送请求后超过 3 分钟创建的,数据库中的数据库表大约有 4000 条记录,我认为它可以通过 JavaScript 解决,但我不确定如何解决。谢谢

 $query = "SELECT * FROM tblRazduzeniUgovori";
if ($result = mysqli_query($con, $query)) {
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td><input type='checkbox' name='brojUgovora[]' value='" . $row['Broj'] . "'/></td>";
echo "<td style='font-size:15px;'>" . $row['Broj'] . "</td>";
echo "<td>" . $row['Kontrolni_Broj'] . "</td>";
echo "<td><span class='label label-success' style='width:90%;'>";
foreach ($kor_id as $key => $val) {
if ($val == $row['Korisnik_ID']) {
echo $kor_ime[$key] . " " . $kor_prezime[$key];
break;
}
}
echo "</span></td>";
echo "<td>" . $row['Datum_Razduzenja'] . "</td>";
echo "<td>" . $row['Ime_Kupca'] . "</td>";
echo "<td>" . $row['Ime_Prodavca'] . "</td>";
echo "<td>" . $row['Cijena'] . " KM</td>";
echo "<td style='padding:6px;'><span class='label label- info' style='width:90%; text-align:center;'><a href='/crm/ugovori/" . $row['Slika'] . "' style='color:white;'>" . $row['Slika'] . "</a></span></td>";
echo "</tr>";
}
}
mysqli_close($con);
return $vrati;
}

最佳答案

首先减少您的查询,仅询问您想要的表字段,例如:

$query = "SELECT Broj,Kontrolni_Broj FROM tblRazduzeniUgovori "

(显然将您需要的其余字段添加到选择中)

第二次使用串联,而不是大量的回声。

$query = "SELECT * FROM tblRazduzeniUgovori";
$output = '';
if ($result = mysqli_query($con, $query)) {
while($row = mysqli_fetch_array($result))
{
$output .= "<tr>";
$output .= "<td><input type='checkbox' name='brojUgovora[]' value='" . $row['Broj'] . "'/></td>";
$output .= "<td style='font-size:15px;'>" . $row['Broj'] . "</td>";
$output .= "<td>" . $row['Kontrolni_Broj'] . "</td>";
$output .= "<td><span class='label label-success' style='width:90%;'>";
foreach ($kor_id as $key => $val) {
if ($val == $row['Korisnik_ID']) {
$output .= $kor_ime[$key] . " " . $kor_prezime[$key];
break;
}
}
$output .= "</span></td>";
$output .= "<td>" . $row['Datum_Razduzenja'] . "</td>";
$output .= "<td>" . $row['Ime_Kupca'] . "</td>";
$output .= "<td>" . $row['Ime_Prodavca'] . "</td>";
$output .= "<td>" . $row['Cijena'] . " KM</td>";
$output .= "<td style='padding:6px;'><span class='label label- info' style='width:90%; text-align:center;'><a href='/crm/ugovori/" . $row['Slika'] . "' style='color:white;'>" . $row['Slika'] . "</a></span></td>";
$output .= "</tr>";
}
}
mysqli_close($con);
echo $output;
}

关于html - 使用 mysql 查询生成大型 html 表非常慢 - 4000+ 行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21212603/

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