快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

MySQL通用查询程序

if(get_magic_quotes_gpc()==1){
   ?>
<html>
<head><title>MySQL通用查询程序</title></head>
<body>
注重本程序需要将PHP配置文件(PHP3为php3.ini,PHP4为php.ini)中的magic_quotes_gpc
设成Off或0,修改后请重新启动Apache.
</body>
</html>
   <?
   exit();
}

set_magic_quotes_runtime(0);

$host = \\'localhost\\';
$db = \\'test\\';
$user = \\'test\\';
$pass = \\'\\';

// [ php/inc/str2url.php ] cvs 1.2
function str2url($path){
   return eregi_replace("%2f","/",urlencode($path));
}
?>

<html>
<head><title>MySQL通用查询程序</title></head>
<body>

<form action="<?echo str2url($PHP_SELF);?>" method="post">
请输入SQL语句:<br>
<textarea name="sql" cols="100" rows="5"><?echo $sql;?></textarea><br>
<input type="submit" name="cmd" value="查询">
<input type="submit" name="cmd" value="执行">
</form>

<?
if($cmd){
   $con = mysql_pconnect($host,$user,$pass) or die(\\'无法连接\\'.$host.\\'服务器\\');
   mysql_select_db($db,$con) or die(\\'无法连接\\'.$db.\\'数据库\\');
   $rst = mysql_query($sql,$con) or die($sql.\\'出错\\');
   if($cmd==\\'查询\\'){
      $num_fields = mysql_num_fields($rst);
      echo \\'<hr>\\';
      echo \\'<table border="1" cellpadding="0" cellspacing="0">\\';
      echo \\'<caption align="center">\\'.$sql.\\'</option>\\';
      echo \\'<tr>\\';
      for($i=0;$i<$num_fields;$i++) echo \\'<th>&nbsp;\\'.mysql_field_name($rst,$i).\\'</th>\\';
      echo \\'</tr>\\';
      while($row=mysql_fetch_row($rst)){
         echo \\'<tr>\\';
         for($i=0;$i<$num_fields;$i++) echo \\'<td>&nbsp;\\'.$row[$i].\\'</td>\\';
         echo \\'</tr>\\';
      }
      echo \\'</table>\\';
      mysql_free_result($rst);
   }
   else echo \\'有 \\'.mysql_affected_rows($con).\\' 行受影响\\';
}
?>

</body>
</html>





返回类别: 教程
上一教程: 同时提取多条新闻中的文本一例
下一教程: PHP和MYSQL合理且有效的结合在一起

您可以阅读与"MySQL通用查询程序"相关的教程:
· 一个简朴的域名注册情况查询程序
· 无数据库的具体域名查询程序PHP版(3)
· 无数据库的具体域名查询程序PHP版(4)
· 无数据库的具体域名查询程序PHP版(5) 
· 无数据库的具体域名查询程序PHP版(2)
    微笑服务 优质保证 索取样品