查看: 2292|回复: 2
|
sql statement
[复制链接]
|
|
Below is my coding and error message
--------------------------------------------------------------------------
1.php
<?php
mysql_connect("localhost","root","1234");
mysql_select_db("spm");
$aa="select * from bookorder";
$bb=mysql_query($aa);
echo "<table width=75% border=1>";
echo"<tr><td>Name<td>ID<td>Contact No<td>Delivery Address<td>Order Time<td>Cartid</tr>";
while(list($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=mysql_fetch_row($bb))
{
echo"<tr>
<td>$a1</td>
<td>$a2</td>
<td>$a3</td>
<td>$a4</td>
<td>$a6</td>
<td><a href=detail1.php?pk=$a7>$a7</a></td>
</tr>
";
}
echo "</table>";
?>
--------------------------------------------------------------------------
请问要如何改这段sql statement? so when i click the value of cartid column
it can come up the detail transaction of that particular value..
this is the error message
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-7\www\spm_projects\transaction\detail1.php on line 16
--------------------------------------------------------------------------
detail1.php
<?php
mysql_connect("localhost","root","1234");
mysql_select_db("spm");
$pk = $_GET['pk'];
$aa="select putbag.cartid,sum(putbag.amt),sum(bookorder.price * putbag.amt)
from book, putbag
where putbag.psn=book.psn
group by putbag.cartid";
$bb=mysql_query($aa);
list($a0,$a1,$a2)=mysql_fetch_row($bb);
echo"<table width=100% border=1>";
echo"<tr>
<td>Cartid<td>$a0</tr>
<tr><td>Total Quantity<td>$a1</tr>
<tr><td>Total Amount (RM)<td>$a2</tr>
";
echo"</table>";
?>
--------------------------------------------------------------------------
thanks.......
[ 本帖最后由 html 于 28-8-2006 05:00 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 28-8-2006 03:59 PM
|
显示全部楼层
what was the error coming out?seens like ok only |
|
|
|
|
|
|
|
楼主 |
发表于 28-8-2006 11:24 PM
|
显示全部楼层
原帖由 8years 于 28-8-2006 03:59 PM 发表
what was the error coming out?seens like ok only
i solve the probelm edi.. just change it like below
$aa="select putbag.cartid,sum(putbag.amt),sum(book.price * putbag.amt)
from book, putbag
where putbag.psn=book.psn and putbag.cartid='".$pk."'
group by putbag.cartid"; |
|
|
|
|
|
|
| |
本周最热论坛帖子
|