我试图用某个SQL查询的结果填充表格,但我不知道为什么它不起作用,继承我的代码:
<?
if(!ceklogin()){
header("Location:index.php");
}
?><?
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>MSystem</title>
<link rel=stylesheet type="text/css" href="style.css">
<LINK href="gaya.css" type=text/css rel=stylesheet>
</head>
<?
//$cfgProgDir = 'phpSecurePages/phpSecurePages/';
//include($cfgProgDir . "secure.php");
include_once("top4.htm");
include_once("conn.php");
$datenow = getdate();
?>
<script type="text/javascript" src="js/calendarDateInput.js">
</script>
<body class="bg">
<table align="center">
<tr>
<td><p align="center"><strong><font color="#000000" size="2">TITLE</font></strong></p></td>
</tr>
<tr>
<td><p align="center"><strong><font color="#000000" size="3"> SMALL TITLE</font></strong></p></td>
</tr>
<tr>
<td><p align="center"><strong><font color="#000000" size="2">Date: <? echo $v_date ?></font></strong></p></td>
</tr>
<tr>
<td><p align=center><strong><font color=#000000 size=2>SMALLER TITLE</font></strong></p></td>
</tr>
<tr>
<td><img src="img/batas.jpg" width="750" height="1" ></td>
</tr>
</table>
<br>
<table class=table width="750" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor=black bgcolor="#DDDDDD" BORDER-COLLAPSE"collapse">
////////// THIS IS THE TABLE
<tr>
<td bgcolor=#444444 align=center><font color=white>Date</font></td>
<td bgcolor=#444444 align=center><font color=white>Type</font></td>
<td bgcolor=#444444 align=center><font color=white>Sender</font></td>
<td bgcolor=#444444 align=center><font color=white>Description</font></td>
<td bgcolor=#444444 align=center><font color=white>Credit</font></td>
<td bgcolor=#444444 align=center><font color=white>Quantity</font></td>
<td bgcolor=#444444 align=center><font color=white>Price</font></td>
</tr>
<?
$blnto = substr($v_date,3,3);
switch($blnto)
{
case 'JAN': {$blntov = '01'; break;}
case 'FEB': {$blntov = '02'; break;}
case 'MAR': {$blntov = '03'; break;}
case 'APR': {$blntov = '04'; break;}
case 'MAY': {$blntov = '05'; break;}
case 'JUN': {$blntov = '06'; break;}
case 'JUL': {$blntov = '07'; break;}
case 'AUG': {$blntov = '08'; break;}
case 'SEP': {$blntov = '09'; break;}
case 'OCT': {$blntov = '10'; break;}
case 'NOV': {$blntov = '11'; break;}
case 'DEC': {$blntov = '12'; break;}
}
$tglto = substr($v_date,0,2);
$thnto = substr($v_date,7,4);
//////////// HERES THE QUERY
$MyQuery = "
select date, type, sender, description, credit, quantity, change
from harjunadip.REPORTENABLEREGAE
WHERE date = '".$thnto."-".$blntov."-".$tglto."'
//test with: WHERE date = '2015-10-05'
order by description
";
//echo $MyQuery;
$curs=ora_open($conn);
ora_parse($curs,$MyQuery, 0);
ora_exec($curs);
$i=1;
$tot_qty_p = 0;
$tot_sal_p = 0;
$tot_qty_v = 0;
$tot_sal_v = 0;
while(ora_fetch($curs) == 1) // WHILE THERE IS A ROW
{
$bgcolor = "";
if ($i % 2 != 1) $bgcolor = "bgcolor=#FFFFCC";
///////// THIS IS THE SUPPOSED TABLE CONTENTS
$content = "
<tr ".$bgcolor.">
<td align=\"center\">".ora_getcolumn($curs,0)."</td>
<td align=\"right\">".ora_getcolumn($curs,1)."</td>
<td align=\"right\">".ora_getcolumn($curs,2)."</td>
<td align=\"right\">".ora_getcolumn($curs,3)."</td>
<td align=\"right\">".number_format(ora_getcolumn($curs,4))."</td>
<td align=\"right\">".number_format(ora_getcolumn($curs,5))."</td>
<td align=\"right\">".number_format(ora_getcolumn($curs,6),2,'.',',')."</td>
</tr>
";
$tot_qty = $tot_qty + ora_getcolumn($curs,5);
$tot_price = $tot_price + ora_getcolumn($curs,6);;
echo $content;
$i++;
}
ora_close($curs);
?>
<tr bgcolor="#444444">
<td align="right" colspan="5"><font color="#FFFFFF">Total :</font></td>
<td align="right"><font color="#FFFFFF"><? echo number_format($tot_qty) ?></font></td>
<td align="right"><font color="#FFFFFF"><? echo number_format($tot_price,2,'.',',') ?></font></td>
</tr>
</table>
</body>
</html>
需要考虑的事项:
查询有效,我已尝试通过替换&#39;&#34;。$ thnto。&#34; - &#34;。$ blntov。&#34; - &#34; 。$ tglto&#34;&#39;与&#39; 2015-10-05&#39;它给了我结果。
该表格出现但只有标题(日期,类型,发送者等)
与数据库的连接也有效,因此它不是连接问题
如果重要的话,我将adobe.inc.php与oci8连接使用
我似乎无法将结果放在所述表上。我试过回应一些随机的东西:
select date, type, sender, description, credit, quantity, change
from harjunadip.REPORTENABLEREGAE
WHERE date = '".$thnto."-".$blntov."-".$tglto."'
//test with: WHERE date = '2015-10-05'
order by description
";
echo 'test1';
$curs=ora_open($conn);
ora_parse($curs,$MyQuery, 0);
echo 'test2';
ora_exec($curs);
echo 'test3';
$i=1;
$tot_qty_p = 0;
$tot_sal_p = 0;
$tot_qty_v = 0;
$tot_sal_v = 0;
while(ora_fetch($curs) == 1) // WHILE THERE IS A ROW
echo 'test4';
{
$bgcolor = "";
if ($i % 2 != 1) $bgcolor = "bgcolor=#FFFFCC";
但只有&#39; test1&#39;出现了,其他人没有。
请帮助,我已经失去了,先谢谢。