php實(shí)現(xiàn)的MySQL通用查詢程序
更新時(shí)間:2007年03月11日 00:00:00 作者:
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語(yǔ)句:<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('無(wú)法連接'.$host.'服務(wù)器');
mysql_select_db($db,$con) or die('無(wú)法連接'.$db.'數(shù)據(jù)庫(kù)');
$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> '.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> '.$row[$i].'</td>';
echo '</tr>';
}
echo '</table>';
mysql_free_result($rst);
}
else echo '有 '.mysql_affected_rows($con).' 行受影響';
}
?>
</body>
</html>
?>
<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語(yǔ)句:<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('無(wú)法連接'.$host.'服務(wù)器');
mysql_select_db($db,$con) or die('無(wú)法連接'.$db.'數(shù)據(jù)庫(kù)');
$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> '.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> '.$row[$i].'</td>';
echo '</tr>';
}
echo '</table>';
mysql_free_result($rst);
}
else echo '有 '.mysql_affected_rows($con).' 行受影響';
}
?>
</body>
</html>
您可能感興趣的文章:
- php基礎(chǔ)之連接mysql數(shù)據(jù)庫(kù)和查詢數(shù)據(jù)
- PHP連接MySQL查詢結(jié)果中文顯示亂碼解決方法
- Php中用PDO查詢Mysql來(lái)避免SQL注入風(fēng)險(xiǎn)的方法
- MySql數(shù)據(jù)庫(kù)查詢結(jié)果用表格輸出PHP代碼示例
- PHP手機(jī)號(hào)碼歸屬地查詢代碼(API接口/mysql)
- PHP訪問(wèn)MySQL查詢超時(shí)處理的方法
- php訪問(wèn)查詢mysql數(shù)據(jù)的三種方法
- php下巧用select語(yǔ)句實(shí)現(xiàn)mysql分頁(yè)查詢
- php查詢mysql數(shù)據(jù)庫(kù)并將結(jié)果保存到數(shù)組的方法
- 從Web查詢數(shù)據(jù)庫(kù)之PHP與MySQL篇
- php查詢mysql大量數(shù)據(jù)造成內(nèi)存不足的解決方法
- PHP查詢MySQL大量數(shù)據(jù)的時(shí)候內(nèi)存占用分析
- 關(guān)于php操作mysql執(zhí)行數(shù)據(jù)庫(kù)查詢的一些常用操作匯總
- php入門(mén)學(xué)習(xí)知識(shí)點(diǎn)一 PHP與MYSql連接與查詢
- php+mysqli批量查詢多張表數(shù)據(jù)的方法
- PHP將MySQL的查詢結(jié)果轉(zhuǎn)換為數(shù)組并用where拼接的示例
相關(guān)文章
PHP array_key_exists檢查鍵名或索引是否存在于數(shù)組中的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇PHP array_key_exists檢查鍵名或索引是否存在于數(shù)組中的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06Zend Studio 無(wú)法啟動(dòng)的問(wèn)題解決方法
今天 Zend Studio 突然無(wú)法啟動(dòng)了,Google 了一下,仍舊無(wú)解。2008-12-12注冊(cè)頁(yè)面之前先驗(yàn)證用戶名是否存在的php代碼
注冊(cè)頁(yè)面之前先驗(yàn)證用戶名是否存在的php代碼,需要的朋友可以參考下2012-07-07php reset() 函數(shù)指針指向數(shù)組中的第一個(gè)元素并輸出實(shí)例代碼
在php中,當(dāng)我們使用next函數(shù)或end函數(shù)將數(shù)組內(nèi)部針指指向數(shù)組最后一個(gè)元素的時(shí)候,如果再需要將內(nèi)部指針指向第一個(gè)元素,可以使用reset() 函數(shù)來(lái)實(shí)現(xiàn),本文章向大家講解reset() 函數(shù)的基本語(yǔ)法及使用實(shí)例,需要的朋友可以參考下2016-11-11laravel 實(shí)現(xiàn)上傳圖片到本地和前臺(tái)訪問(wèn)示例
今天小編就為大家分享一篇laravel 實(shí)現(xiàn)上傳圖片到本地和前臺(tái)訪問(wèn)示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10thinkphp路由規(guī)則使用示例詳解和偽靜態(tài)功能實(shí)現(xiàn)(apache重寫(xiě))
這篇文章主要介紹了thinkphp路由規(guī)則使用示例詳解和偽靜態(tài)功能實(shí)現(xiàn)(apache重寫(xiě)),需要的朋友可以參考下2014-02-02