当前位置:Gxlcms > PHP教程 > php实现的简单mysql工具(执行多条sql语句)

php实现的简单mysql工具(执行多条sql语句)

时间:2021-07-01 10:21:17 帮助过:3人阅读

'; foreach($row as $k=>$v){ $str .= ""; } $str .= ""; } $str .= ""; foreach($row as $k=>$v){ $str .= ""; } $str .= ""; } @mysql_free_result($result); echo "
本文介绍下,php实现的一个简单的mysql工具,可能执行多条sql语句,有需要的朋友参考下。

代码如下:



";

//解决不输入无分号找不到sql的问题
for($i=0;$i';
  
  $result = mysql_query(stripslashes($sql));
 
  if (!$result) {
   echo "Could not successfully run query ($sql) from DB: " . mysql_error()."";   
   continue;
  }
 
  if (mysql_num_rows($result) == 0) {
   echo "No rows found, nothing to print so am exiting";
   continue;
  }
 
  // While a row of data exists, put that row in $row as an associative array
  // Note: If you're expecting just one row, no need to use a loop
  // Note: If you put extract($row); inside the following loop, you'll
  //       then create $userid, $fullname, and $userstatus
  $str = "";
  while ($row = mysql_fetch_assoc($result)) {
   if($str == ""){
    $str = '
".$k."
".$v."
"; echo $str; echo "
"; } } ?>

人气教程排行