• PHP获取MySQL数据库中的整张表的数据


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>获取数据表中的数据</title>
    </head>
    <body>
    <?php
        $table= 'grades';
        $database= 'sel';
        $link= @mysqli_connect('localhost','root','',$database) or die('错误:'.mysqli_connect_error());
        mysqli_set_charset($link,'utf8');
        $rs= mysqli_query($link,'select * from '.$table);   
        $list= mysqli_fetch_all($rs,MYSQLI_ASSOC);  
    ?>
        <table>
            <tr>
                <?php foreach($list as $key=>$value): ?>
                    <th><?php echo array_keys($value)[$key] ?></th>
                <?php endforeach;?>
            </tr>
            <?php foreach($list as $rows):?>
            <tr>
                <?php for($i=0; $i<count($list); $i++):?>
                    <td><?php echo $rows[array_keys($rows)[$i]]?></td>
                <?php endfor;?>
            </tr>
            <?php endforeach;?>
        </table>
    </body>
    </html>
  • 相关阅读:
    使用kendynet构建异步redis访问服务
    使用kendynet编写网关服务
    作为前端,我为什么选择 Angular 2?
    你必须知道的Javascript 系列
    JS日期(Date)处理函数总结
    JS数组(Array)处理函数总结
    消息推送之APNS
    消息推送之GCM
    Linux常用命令大全
    Sequential Container
  • 原文地址:https://www.cnblogs.com/SharkJiao/p/14087606.html
Copyright © 2020-2023  润新知