<body bgcolor=#ffffdd>
<b>database</b>: test <b>table</b>: student, subject, regist<br>
<form action=''>
<textarea name=q rows=4 cols=90 wrap=off>
select * from student join regist
where student.sid = regist.sid
order by regist.ryear,regist.sid
</textarea>
<input type=submit value=query>
</form>
<?
$c = mysql_connect("127.0.0.1:3306","admin","p");
if (isset($_REQUEST["q"]) && strlen($_REQUEST["q"]) > 5) {
$q = stripslashes($_REQUEST["q"]);
$result = mysql_db_query("test",$q);
} else {
$q = "select * from student";
$result = mysql_db_query("test",$q);
}
while($row = mysql_fetch_array($result)) {
for($i=0;$i<count($row);$i++)
if(isset($row[$i])) echo $row[$i]."_";
echo "<hr>";
}
mysql_close($c);
?>
|