//列出所有資料庫
$result =mysql_list_dbs($localmat);
while ($row = mysql_fetch_object($result)) {
echo "資料庫:";
echo $row->Database . "\n";
}
echo "
";
//資料庫名稱,列出所有table
if ($dname!="")
{
$result =mysql_list_tables($dname);
echo $dname."的table
";
while ($row = mysql_fetch_row($result)) {
print "Table: $row[0]\n";
}
}
echo "
";
//table名稱,列出所有欄位
if ($tname!="")
{
mysql_select_db($dname, $localmat);
$result = mysql_query("select * from $tname", $localmat);
echo mysql_error();
//劃出欄位名稱
echo "
表格:$tname | ";"; $i++; $meta = @mysql_fetch_field ($result); echo $meta->name." | " ;
}
echo "
";
$sname=strtolower($sname);
if ($sname!="")
{
mysql_select_db($dname, $localmat);
$result = mysql_query($sname, $localmat);
echo mysql_error();
//echo $localmat;
}
$aa=explode(" ", $sname);
switch ($aa[0]) {
case 'insert':
$try="into";
break;
case 'update':
$try="update";
break;
case 'delete':
$try="from";
break;
default :
$try="select";
break;
}
echo $sname."字串長度
";
//echo $try."驗證
";
$str1=substr($sname,strpos( $sname, $try ));
$str2=explode(" ", $str1);
if ($try!="select" and $try!="") $sname="select * from ".$str2[1]." where 1";
//echo $sname;
if ($sname!="" and $dname!="") {
mysql_select_db($dname, $localmat);
$result = mysql_query($sname, $localmat);
echo mysql_error();
//劃出欄位名稱
echo "
$i"; $i++; $meta = @mysql_fetch_field ($result); echo $meta->name." | " ;
$row_Recordset1[$j] | ";
}
?>
全站熱搜
留言列表