<?
require('connect.php');
mysql_select_db('CAT_CDMA') or die("เลือกฐานข้อมูลไม่ได้");
$sql="SELECT price,count(m_code) AS num_of_product ,ROUND((sum(price)*(discount/100)),2) as discount_value, sum(price) as sum_price FROM addr2 ,detial1
where addr2.run_no = (select max(run_no) from addr2)
and addr2.run_no = detial1.run_no_from_addr2 GROUP BY m_code";
$db_query=mysql_db_query('CAT_CDMA',$sql);
$num_rows = mysql_num_rows($db_query);
if($num_rows < 3)
{
<?
$strSQL = "
SELECT price,count(m_code) AS num_of_product ,ROUND((sum(price)*(discount/100)),2) as discount_value, sum(price) as sum_price FROM addr2 ,detial1
where addr2.run_no = (select max(run_no) from addr2)
and addr2.run_no = detial1.run_no_from_addr2 GROUP BY m_code";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
.....
.....
.....