我想知道是否有人可以告诉我如何索引我的MySQL查询。从只有120行的数据库加载需要永远。
我的查询是:
$sql = "SELECT firstname, lastname, email, phone, username, password, status,
memberview, statuschangedate FROM csvdata ORDER BY lastname ";
$sth= $DBH->prepare($sql);
$sth->execute();
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
code
}
感谢您的时间!
EDITED --------------------------
这是实际发生的事情 -
$sql = "SELECT firstname, lastname, email, phone, username, password, status, memberview, statuschangedate FROM csvdata ORDER BY lastname ";
$sth= $DBH->prepare($sql);
$sth->execute();
$i = 0;
echo "<table class='alltable'>
<tr class='firsttr' style='background:gray;'>
<td>First Name </td>
<td>Last Name </td>
<td>Email </td>
<td>Phone </td>
<td>Username </td>
<td>Password </td>
<td>Status </td>
<td>Memberview</td>
<td>Status Change Date</td>
<td>#</td>
</tr>
";
$j = 0;
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$csvfirst = $row;
$csvfirstname = $csvfirst['firstname'];
$csvlastname = $csvfirst['lastname'];
$csvemail = $csvfirst['email'];
$csvphone = $csvfirst['phone'];
$csvusername = $csvfirst['username'];
$csvpassword= $csvfirst['password'];
$csvstatus = $csvfirst['status'];
$csvmemberview = $csvfirst['memberview'];
$csvstatuschange = $csvfirst['statuschangedate'];
$memberfirstnamearray[$j] = $csvfirstname;
$memberlastnamearray[$j] = $csvlastname;
$memberemailarray[$j] = $csvemail;
$memberphonearray[$j] = $csvphone;
$j++;
$i++;
echo "
<tr>
<td>
$csvfirstname
</td>
<td>
$csvlastname
</td>
<td>
$csvemail
</td>
<td>
$csvphone
</td>
<td>
$csvusername
</td>
<td>
$csvpassword
</td>
<td>
$csvstatus
</td>
<td>
$csvmemberview
</td>
<td>
$csvstatuschange
</td>
<td>
$i
</td>
</tr>
";
}
$_SESSION['firstnameexport'] = $memberfirstnamearray;
$_SESSION['lastnameexport'] = $memberlastnamearray;
$_SESSION['emailexport'] = $memberemailarray;
$_SESSION['phoneexport'] = $memberphonearray;
$_SESSION['num'] = $j;
echo "
</table>";
}
所以大约有120名员工从数据库中获取,需要大约20秒才能加载。我将此表包含在div
中,而不是一个按钮,一旦计时,jquery将visibility: none
更改为可见并向下滑动。
如果您还有其他需要,请告诉我们!
EDITED ----------------------
来自使用desc csvdata - 这是员工永远的需要。
'id', 'int(11)', 'NO', 'PRI', NULL, 'auto_increment'
'firstname', 'varchar(105)', 'YES', '', NULL, ''
'lastname', 'varchar(105)', 'YES', '', NULL, ''
'email', 'varchar(105)', 'YES', '', NULL, ''
'phone', 'varchar(105)', 'YES', '', NULL, ''
'username', 'varchar(105)', 'YES', '', NULL, ''
'password', 'varchar(105)', 'YES', '', NULL, ''
'status', 'varchar(105)', 'YES', '', NULL, ''
'memberview', 'varchar(105)', 'YES', '', NULL, ''
'statuschangedate', 'varchar(105)', 'YES', '', NULL, ''
'notes', 'varchar(1000)', 'YES', '', NULL, ''
'customernotes', 'varchar(1000)', 'YES', '', NULL, ''
答案 0 :(得分:0)
嘿伙计们,你知道这是什么问题吗?
这是JQuery slidedown()延迟了它所以我只是将它改为css以显示:table并且工作得很完美!
代码 -
<script>
$(".viewall").click(function () {
//dropdown.bind('change', function(){
//$(".alltable").slideDown(0,function(){
//});
$(".alltable").css("display", "table");
$(".alltable tr").css("display", "table-row");
$(".alltable td").css("display", "table-cell");
//$(".alltable tr").slideDown(0,function(){
//});
//$(".alltable td").slideDown(0,function(){
//});
});
$(".closeall").click(function () {
//dropdown.bind('change', function(){
/*$(".alltable").slideUp(200,function(){
});*/
$(".alltable").css("display", "none");
$(".alltable tr").css("display", "none");
$(".alltable td").css("display", "none");
/*$(".alltable tr").slideUp(200,function(){
});
$(".alltable td").slideUp(200,function(){
});*/
});
</script>