<form action=reportvdo.php><font size=0>
<select name=roption size=4>
<option value=1 selected>1. Detail of borrow and borrowd (no input value)
<option value=2>2. Group by vid and count (no input value)
<option value=3>3. Link 3 table with order by (no input value)
<option value=4>4. User report 3 (bdate - input value to select)
</select>
<input name=voption value="2001-12-21"><input type=submit value=Report_VDO>
</form>
<?
require("connect.php");
if (!$roption) { exit; }
switch ($roption) {
case "1":
$sql="select * from borrow,borrowd where borrow.bid = borrowd.bid";
$result = mysql_db_query($db,$sql);
echo "$sql<br>";
while ($object = mysql_fetch_object($result)) {
echo $object->bid."-".$object->vid."-".$object->bdate."-".$object->sdate."<br>";
}
break;
case "2":
$sql="select vid,count(vid) from borrow,borrowd where borrow.bid = borrowd.bid ";
$sql=$sql."group by borrowd.vid";
$result = mysql_db_query($db,$sql);
echo "$sql<br>";
while ($data = mysql_fetch_row($result)) {
echo "$data[0] - $data[1]<br>";
}
break;
case "3":
$sql="select bdate,sdate,vid,vname,bflag from borrow,borrowd,story ";
$sql=$sql."where borrow.bid = borrowd.bid and left(borrowd.vid,8) = story.vid8 ";
$sql=$sql."order by borrow.bdate desc";
$result = mysql_db_query($db,$sql);
echo "$sql<br>";
while ($data = mysql_fetch_row($result)) {
echo "$data[0] | $data[1] | $data[2] | $data[3] | $data[4]<br>";
}
break;
case "4":
$sql="select bdate,sdate,vid,vname,bflag from borrow,borrowd,story ";
$sql=$sql."where borrow.bid = borrowd.bid and left(borrowd.vid,8) = story.vid8 ";
$sql=$sql."and borrow.bdate = '$voption' and borrowd.bflag = 'S'";
$result = mysql_db_query($db,$sql);
echo "$sql<br>";
while ($data = mysql_fetch_row($result)) {
echo "$data[0] | $data[1] | $data[2] | $data[3] | $data[4]<br>";
}
break;
}
mysql_close($connect);
?>
จำนวน : 53 บรรทัด