<?php
header('Content-Type:text/html;Charset=utf-8');
$db = new mysqli();
$db->connect('localhost','root',12345,'test');
$sql='select * from category';
$query=$db->query($sql);


while($rs=mysqli_fetch_array($query)){
    $result[]=$rs;
}
$i=0;
print_r($result);
echo '<hr>';
foreach($result as $key=>$value){
    $i+=1;
    if($i%2==0){
    echo $key.' ';
        echo $value.'<hr>';
    }
}
$query->free();
$db->close();

标签: PHP

添加新评论