国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL通用查詢程序

2024-07-24 12:56:50
字體:
供稿:網(wǎng)友

if(get_magic_quotes_gpc()==1){
   ?>
<html>
<head><title>mysql通用查詢程序</title></head>
<body>
注意本程序需要將php配置文件(php3為php3.ini,php4為php.ini)中的magic_quotes_gpc
設(shè)成off或0,修改后請(qǐng)重新啟動(dòng)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">
請(qǐng)輸入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="執(zhí)行">
</form>

<?
if($cmd){
   $con = mysql_pconnect($host,$user,$pass) or die('無法連接'.$host.'服務(wù)器');
   mysql_select_db($db,$con) or die('無法連接'.$db.'數(shù)據(jù)庫');
   $rst = mysql_query($sql,$con) or die($sql.'出錯(cuò)');
   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>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 疏勒县| 桃园县| 江达县| 江川县| 固始县| 滁州市| 贵溪市| 凤翔县| 阳信县| 昭平县| 民丰县| 颍上县| 青浦区| 金塔县| 土默特右旗| 綦江县| 班玛县| 广宗县| 会同县| 尚义县| 偃师市| 芜湖县| 陕西省| 阳信县| 百色市| 闸北区| 全州县| 甘孜| 额尔古纳市| 固镇县| 大同县| 普陀区| 观塘区| 边坝县| 隆安县| 垣曲县| 海兴县| 瑞金市| 永城市| 枣阳市| 宁强县|