网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 112.87.17.117
Old 2015-05-21, 07:21 AM
West University Place West University Place is offline
初级会员
 
Join Date: 2008-07-31
Posts: 4
West University Place 现在声名狼藉
Default php查询MYSQL数据库里的记录并显示出来,怎么样能让速度快点?

我平时一直是用mysql_fetch_array($result)函数组织数据。发现数据量大的时候速度会慢下来,不知道大家都怎么查询和显示。

听说可以把数据全部查询出来后由JS去组织,这样能把一部分负担分给客户机,这方法可行吗?哪位有这方面的资料?


下面是我常用的显示方法:
$result=mysql_query('select id,username,address,phone from userlist order by id desc');
while ($rs=mysql_fetch_array($result)){
echo $rs["id"].",";
echo $rs["username"].",";
echo $rs["mydate"].";";
}
Reply With Quote
  #2   IP: 112.87.17.117
Old 2015-05-21, 07:22 AM
Napa Napa is offline
初级会员
 
Join Date: 2011-11-21
Posts: 1
Napa 现在声名狼藉
Default

Code:
<?php
//这种方法不错.
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* prepare statement */
if ($stmt = $mysqli->prepare("SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) {
    $stmt->execute();

    /* bind variables to prepared statement */
    $stmt->bind_result($col1, $col2);

    /* fetch values */
    while ($stmt->fetch()) {
        printf("%s %s\n", $col1, $col2);
    }

    /* close statement */
    $stmt->close();
}
/* close connection */
$mysqli->close();

?>
mysql_fetch_array

它打印两种方式:一种是关联数组;一种是索引数组

如果只需要一结果的话,别用它
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 09:23 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.