我正在使用类 'chosen-select' 来加载所有产品名称。当用户单击 product_select 时,加载需要很长时间。可以做些什么来提高性能。
<select class='chosen-select' data-placeholder="Choose a product..." id="product_select">
<option></option>
<?php
include 'connection.php';
$query = "SELECT * FROM " . $table_name;
$result = mysqli_query($con, $query);
$results = array();
while ($line = mysqli_fetch_assoc($result))
{
$results[] = $line;
}
$i = 0;
foreach ($results as $r)
{
$i++;
echo "<option value=" . $r['id'] . ">" . $r['Product_name'] . "</option>";
}
?>
</select>
<script>
$('#product_select').chosen({max_selected_options: 1});
</script>