欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-05 16:21:23
...
'; 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 "
"; } } ?>