1 $dbname=DB_NAME; 2 $host=DB_HOST; 3 $port=DB_PORT; 4 $user =DB_USER; 5 $password=DB_PWD; 6 7 $mysqli = new \mysqli($host, $user, $password, $dbname,$port); 8 9 //$sql="explain select * from k_user "; 10 $sql="select * from k_user limit 1"; 11 //$sql="desc k_score_log"; 12 //$sql="ALTER TABLE `k_user` ENGINE=MyISAM;"; 13 //$sql="ALTER TABLE `k_user` ENGINE=InnoDB;"; 14 $result = $mysqli->query($sql); 15 16 if($result){ 17 if(is_object($result)){ 18 echo ‘<div style="margin:0 auto;width: 1000px;height: 800px;"><div style="width: 1000px;overflow:auto">‘; 19 echo "<table style=‘border-color: #efefef;‘ width=‘1000px‘ border=‘1px‘ cellpadding=‘5px‘ cellspacing=‘0px‘>"; 20 $show_title=true; 21 $colums=0; 22 while ($row = $result->fetch_array(MYSQLI_ASSOC)) { 23 $header_str=""; 24 $content_str=""; 25 foreach($row as $key=>$value){ 26 if($show_title){ 27 $colums++; 28 $header_str.="<td>$key</td>"; 29 } 30 $content_str.="<td>$value</td>"; 31 } 32 33 if(!empty($header_str)){ 34 echo "<tr style=‘font-weight: bold‘>$header_str</tr>"; 35 } 36 echo "<tr>$content_str<tr>"; 37 $show_title=false; 38 } 39 echo "</table>"; 40 echo "</div>"; 41 echo "<div style=‘margin-top:20px;float:right;font-weight:bold;‘>共计".$result->affected_rows."行".$colums."列</div>"; 42 echo ‘</div>‘; 43 $result->close(); 44 }else{ 45 echo True; 46 } 47 48 } 49 50 $mysqli->close();