php动态数组的用法

180it 2021-06-13 PM 1162℃ 0条
// 创建连接
$con = new mysqli($servername, $username, $password, $dbname);
// Check conection
if ($con->connect_error) {
    die("连接失败: " . $con->conect_error);
}
 
$sql = "SELECT * FROM table limit 0,1000";
$result = $con->query($sql);
 
if ($result->num_rows > 0) {
    // 输出数据
    $mydata = array();
    while($row = $result->fetch_assoc()) {
 
        $mydate = '2019/04/29';
 
 
        $my_post = array(
            'col1'    => $row["col1"],
            'col2'  => $row["col2"],
            'col3'     => '2019-04-29 10:00:00'
            
        );
        $mydata[] = $my_post;
      
 
    }
} else {
    echo "0 结果";
}
$con->close();
 
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

php动态数组的用法