在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 $mysqli->set_charset("utf8"); 9 $sql=trim($_POST["sql_content"]); 10 $result = $mysqli->query($sql); 11 12 13 $data=array(); 14 $data["check_sql"]=$sql; 15 $data["result_str"]=""; 16 $data["total_str"]=""; 17 18 if($mysqli->errno>0){ 19 $data["result_str"]="更新失败"; 20 $data["total_str"]="<div style='margin-top:20px;font-weight:bold;margin-bottom: 10px'>".$mysqli->error."</div>"; 21 }else{ 22 if(is_object($result)){ 23 $data["result_str"].="<table width='100%' border='1px' cellpadding='5px' cellspacing='0px' >"; 24 $show_title=true; 25 $colums=0; 26 while ($row = $result->fetch_array(MYSQLI_ASSOC)) { 27 $header_str=""; 28 $content_str=""; 29 foreach($row as $key=>$value){ 30 if($show_title){ 31 $colums++; 32 $header_str.="<td>$key</td>"; 33 } 34 $content_str.="<td>$value</td>"; 35 } 36 37 if(!empty($header_str)){ 38 $data["result_str"].= "<tr style='font-weight: bold'>$header_str</tr>"; 39 } 40 $data["result_str"].="<tr>$content_str<tr>"; 41 $show_title=false; 42 } 43 $data["result_str"].="</table>"; 44 $data["result_str"].="</div>"; 45 $data["total_str"]="<div style='margin-top:20px;font-weight:bold;margin-bottom: 10px'>共计 ".$mysqli->affected_rows."行 ".$colums."列</div>"; 46 $result->close(); 47 }else{ 48 $data["result_str"]="更新成功"; 49 $data["total_str"]="<div style='margin-top:20px;font-weight:bold;margin-bottom: 10px'>共计 ".$mysqli->affected_rows."行</div>"; 50 } 51 } 52 $mysqli->close();
|
2022-08-30
2022-08-17
2022-11-06
2022-08-18
2022-07-18
请发表评论