www.gusucode.com > 搜一次CMS电影程序 PHP 1.5源码程序 > admin/tools/admin_sql.php
<?php /* '************************************************************************************************** ' 软件名称: 搜一次 Content Management System ' 版本编号: Version 1.X ' 官方网站: http://www.syccms.com ' 官方论坛:http://bbs.syccms.com ' 版权所有: 搜一次开发团队 无痕(QQ:512591) ' 法律顾问: 杭州市元茂律师事务所 严飞律师 ' 郑重声明: ' 1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息; ' 2、搜一次网络事业部保留此软件的法律追究权利 '************************************************************************************************** */ include "../../include/conn.php"; include "../../include/function.php"; include "../admin_loginstate.php"; include "../admin_version.php"; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>SQL高级操作</title> <link rel="stylesheet" type="text/css" href="../images/style.css"> <script language="javascript" src="../js/jquery.Js"></script> <script language="javascript"> $("#execu").click(function(){ var sql=$("#sql").val(); if (sql=="") { $("#sql").css("border","1px solid red"); return false; } }) </script> </head> <body leftmargin="1" topmargin="0" marginwidth="0" marginheight="0"> <?php $action=SafeRequest("action","get"); switch($action){ case 'exe': main(); executeresult(); break; default: main(); break; } ?> <div class="r_main"> <div class="r_content"> <div class="r_content_1"> <?php function main(){ ?> <div class="container" id="cpcontainer"> <form method="post" action="?action=exe" name="form1"> <table class="tb_style" width="98%" align="center"> <tr> <td class="td_title">SQL语句执行操作</td> </tr> <tr> <td class="td_border" align="center"> <textarea rows="5" name="sql" id="sql" cols="80" ></textarea> </td> </tr> <tr> <td class="td_border" align="center"> <input type="submit" class="rb1" id="execu" value="执行SQL"> <input type="reset" value="清除SQL" class="rb1"> </td> </tr> </table> </form></div> <?php } function executeresult(){ global $db; $n=0; $sql=SafeRequest("sql","post"); $sql=stripslashes($sql); if(strtolower(substr($sql,0,6))=="select"){ $isselect="true"; } else{ $isselect="false"; } // die($sql); ?> <!--<table class="tb_style" cellpadding="0" cellspacing="0" border="0" width="98%" align="center"> <tr> <td class="td_title"> 错误号</td> <td class="td_title"> 来源</td> <td class="td_title"> 描述</td> <td class="td_title">帮助</td> <td class="td_title"> 帮助文档</td> </tr> <tr> <td class="td_border"></td> <td class="td_border"></td> <td class="td_border"></td> <td class="td_border"></td> <td class="td_border"></td> </tr> --> <?php if($db->query($sql)){ $num=mysql_affected_rows(); ?> <table class="tb_style" border="0" cellpadding="0" cellspacing="0" width="98" align="center"> <?php if($isselect=="true"){ $results=$db->query($sql); $rows=$db->fetch_array($results); ?> <tr> <?php foreach($rows as $k=>$v){?> <td class="td_title" height="30" nowrap> <?php echo $k?></td> <?php } ?> </tr> <?php $results=$db->query($sql); while($rows=$db->fetch_array($results)){?> <tr> <?php foreach( $rows as $k=>$v){ ?> <td class="td_border" nowrap height="25"> <?php echo $v?></td> <?php } ?> </tr> <?php } } else{ ?> <tr> <td class="td_title" height="30"> 执行结果</td> </tr> <tr> <td class="td_border" height="25"> <?php echo $num?>条记录受影响。 </td> </tr> <?php } ?> </table> <?php }//有结果 else{ ?> <table class="tb_style" cellpadding="0" cellspacing="0" border="0" width="98%" align="center"> <tr> <td class="td_title" width="50"> 错误号</td> <td class="td_title"> 错误信息</td> </tr> <tr> <td class="td_border"><?php echo mysql_errno()?></td> <td class="td_border"><?php echo mysql_error()?></td> </tr> </table> <?php } } ?> <TABLE width="100%" align="center" cellspacing="1" class="tb_style"> <TR> <TD valign="top" class="td_title"><strong> <br> 常用语句对照<br> </strong><br> <p> <strong>1.查询数据</strong></p> <p> select * from s_video 查询所有数据</p> <p> select * from s_video where S_ID=1000 查询指定ID数据</p> <p> <strong>2.删除数据</strong></p> <p> delete from s_video 删除所有数据</p> <p> delete from s_video where S_ID=1000 删除指定的第几条数据</p> <p> delete from s_video where S_Author Like '%周星星%' 删除S_Author字段里有"周星星"的数据<br> </p> <p><strong> 3.修改数据<br> <br> </strong>update s_video set S_Hits=1 将所有S_Hits字段里的值修改成"1" <br> <br> <strong> </strong>update s_video set S_Hits=1 where S_ID=1000 指定的第几条数据把S_Hits字段里的值修改成"1" <br> <br> </p> </TD> </TR> </TABLE> </div> </div> </div> </body> </html>