Copy codeThe Code is as follows: <? Php
$ Str_ SQL _read = "select count (*) as num from userinfo ";
$ Str_ SQL _del = "delete from userinfo where id = 1 ";
$ Res = link_mysql ("read", $ str_ SQL _read );
$ Res_del = link_mysql ("delete", $ str_ SQL _del );
Echo $ res_del. "<br/> ";
While ($ row = mysql_fetch_assoc ($ res ))
{
Echo "<font style = 'font-size: 25px; color: red; '>". $ row ['num']. "</font> <br/> ";
}
?>
<? Php
Function link_mysql ($ opt, $ str_ SQL)
{
$ Con = mysql_connect ("localhost", "root", "root") or die ('not connected: '. mysql_error ());
Mysql_set_charset ("gbk", $ con );
// If you donot know how to use this function, find it defination;
Mysql_select_db ("website", $ con );
Switch ($ opt ){
Case "read ":
$ Res = mysql_query ($ str_ SQL );
Break;
Case "update ":
Case "delete ":
Case "insert ":
$ Res = mysql_query ($ str_ SQL );
Break;
}
Mysql_close ();
Return $ res;
}
?>