|
 |
|
อยากถามว่า ถ้าจะคำนวนหาจำนวนสินค้าที่ถุกยืมไปอะคับ จะใช้ยังไง |
|
 |
|
|
 |
 |
|
อยากถามว่า ถ้าจะคำนวนหาจำนวนสินค้าที่ถุกยืมไปอะคับ จะใช้ยังไง คือ เอาจำนวนจริง ลบกับจำนวนที่ถูกยืม รึป่าว แล้วต้องเอาไปใส่ในเบสไหนอะคับ ช่วยตอบที
อันนี้โค้ดต่อเบสคับ
Code (PHP)
<?
if(!isset($_SESSION)) {
session_start();
}
include("connect.php");
$mem_id=$_SESSION["mem_id"];
$name=$_POST["pro_name"];
$isbn=$_POST["pro_ISBN"];
$price=$_POST["price_pro"];
$id_pro=$_POST["del_cart"];
$id = $_SESSION["user_id"];
$i = $_POST["pro_amount"];
//if ($_SESSION["position"]=="admin") {
$sql= "insert into borrow(id_pro,pro_name,pro_ISBN,date_borrow,price_pro,member_idcard) VALUES ('$id_pro','$name','$isbn',CURRENT_TIMESTAMP,'$price',$mem_id)";
//}
while($i<=strNum){
$sql = "SELECT pro_amount-pro_borrow FROM book , borrow";
$i++;
}
echo $sql;
$result=mysql_query($sql);
if($result==true) {
echo "????????????????????";
}
else{
echo "kkkkkkkkkkkkkkkkkkkkkkkk";
}
?>
<script language="javascript">
// window.location.href="summitborrow.php";
</script>
อันนี้โค้ดตะกร้าคับ
Code (PHP)
<?
if(!isset($_SESSION)) {
session_start();
}
include("connect.php");
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"/>
<script language="javascript">]
function edt(id) {
if(confirm("กดปุ่ม OK เพื่อยืนยันการแก้ไขข้อมูล !!!")==true) {
window.location.href = "chk_cart.php?id_pro="+id;
}
}
function edl(id) {
if(confirm("กดปุ่ม OK เพื่อยืนยันการแก้ไขข้อมูล !!!")==true) {
window.location.href = "summit_cart.php?id_pro="+id;
}
}
</script>
<body>
<form name="frm_cart" action="chk_cart.php" method="post" >
<table width="900" border="1" >
<tr bgcolor="#CC9900" height="30" valign="middle">
<td width="55" align="center">ลำดับที่</td>
<td align="center">ชื่อรายการ</td>
<td align="center">ประเภทรายการ</td>
<td width="128" align="center">ราคาจอง (บาท)</td>
<td width="50" align="center">ลบ</td>
</tr>
<? //while($rs=mysql_fetch_array($result)) { ?>
<?
//============ ทำการแสงรายการที่ได้เลือกว่ามีกี่รายการ
$strNum=0;
$strTotal=0;
for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
{
//============ เลือกว่ารายการสินค้าใดบ้าง
$sql="select * from book where id_pro='".$_SESSION["strProductID"]["$i"]."' ";
$id_pro=$_SESSION["strProductID"]["$i"];
echo $id_pro;
$result=mysql_query($sql);
$rs=mysql_fetch_array($result);
if($rs != "" && $rs != null) {
$strNum++;
//=============เลือกแอดลงเบส
?>
<tr>
<td align="center"><?=$strNum?></td>
<td><input name="pro_name" type="hidden" id="pro_name" value="<?=$rs["pro_name"]?>"><?=$rs["pro_name"]?></td>
<td><input name="pro_type" type="hidden" id="pro_type" value="<?=$rs["pro_type"]?>"><?=$rs["pro_type"]?></td>
<td align="right"><input name="price_pro" type="hidden" id="price_pro"
value="<?=number_format($rs["price_pro"],2)?>"><?=number_format($rs["price_pro"],2)?></td>
<input name="del_cart" type="hidden" id="del_cart" value="<?=$id_pro?>">
<input name="pro_ISBN" type="hidden" id="pro_ISBN" value="<?=$rs["pro_ISBN"]?>">
<input name="pro_amount" type="hidden" id="pro_amount" value="<?=$rs["pro_amount"]?>">
<input name="mem_id" type="hidden" id="mem_id" value="<?=$_SESSION["mem_id"]?>">
<td align="center"><img src="image/No.png" width="32" height="32" onClick="edt('<?=$rs['id_pro']?>');" style="cursor:hand;"/></td>
</tr>
<? } else if (isset($_GET['empty'])){
//Clear Cart by destroying all the data in the session
session_destroy();
//Clear the URL variables
}
$strTotal=$strTotal+$rs["price_pro"];
}
?>
<tr>
<td colspan="3" align="right" bgcolor="#99FF66">ยอดราคาจอง : </td>
<td align="right"><?=number_format($strTotal,2,".",",");?></td>
<td align="center" bgcolor="#99FF66">บาท</td>
</tr>
</table>
<table width="900" border="0">
<tr>
<input type="submit" name="ตกลง" ></td>
<td><a href="?empty"><input type="reset" name="ยกเลิก"></td>
<td><a href="book_store_1.php"><input type="button" onClick="" value="ย้อนกลับ"></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS, JavaScript

|
|
 |
 |
 |
 |
Date :
2010-10-13 17:03:36 |
By :
napatpom |
View :
944 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณก็เก็บ วันที่ สถานะของสิ่งของ ที่ถูกยืมไวสิครับว่า อันได้ ยังไม่ถูกยืม อันไหนที่ถูกยืมอยู่
ให้ผมแนะนำนะครับ สร้าง table ถูกยืมมาเลยจะสะดวกกว่าครับ
|
ประวัติการแก้ไข 2010-10-13 17:10:32
 |
 |
 |
 |
Date :
2010-10-13 17:09:22 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะทำตั้งแต่ขั้นตอนการบันทึกรายการยืมน่ะครับ คือในสิ้นค้านั้น ๆ ก็ให้สร้างฟิวด์ว่ายิมไปกี่ตัว จะง่ายต่อการนำไปใช้
|
 |
 |
 |
 |
Date :
2010-10-13 17:10:44 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือต้องใช้session array รึป่าวคับ แล้ว ถ้าสร้างตารางไหม่ ต้องเก็บไว้ตอนที่ลงตระกร้า หรือ ตอนที่กดปุ่มไปแร้ว แร้วผมังติดว่า ค่าที่ได้มาจากในตะกร้า มันได้ค่าสุดท้ายมาอันเดียวอะคับ ไม่รุ้จะแก้ยังไง คือ สมมุติ ใส่ไป5 แต่มันไม่ได้เกบไป5อัน
มันเกบอันสุดท้ายไปอันเดียวอะคับ ช่วยผมที
|
 |
 |
 |
 |
Date :
2010-10-13 19:19:43 |
By :
napatpom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ให้สร้าง table มา 1 table นะครับ เพื่อทำการเก็บสถานะ ของการยืม หลังจากกดปุ่มนะครับ ก็ให้ทำการ insert ข้อมูลที่ได้ทำการยืม เข้าไป
ส่วนที่คุณบอกว่า ใส่ไป5 แต่มันไม่ได้เก็บไป5อันมันเก็บอันสุดท้ายไปอันเดียวอะคับ ผมงงครับ
|
 |
 |
 |
 |
Date :
2010-10-13 20:01:05 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก้ คือ สมมุติแอดสินค้าเข้าไปในตะกร้าอะคับ 5 อย่าง พอกดปุ่มแร้ว ค่าที่มันส่งไปมีแค่ค่าข้อมูลสุดท้ายในหน้าตะกร้าที่แอดลงเบสไปอะคับ คือว่าผมต้องทำเปนarrayรึป่าว คือผมไม่ค่อยถนัดarrayอะคับ
|
 |
 |
 |
 |
Date :
2010-10-13 21:06:50 |
By :
napatpom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำ textbox รับ หรือไม่ก็เขียนให้ +1 จากค่าที่รับมา เช่น ค่าเริ่มต้นเท่ากับ 0 ถ้ากดเพิ่มก็ให้ +1 ไป และถ้าเพิ่มอีกก็ให้ +1อีก
ประมาณนี้ครับ
|
 |
 |
 |
 |
Date :
2010-10-13 21:58:59 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|