DADB.class.php文件的代碼怎么寫
問題描述
<h2>大蘋果購物網</h2>
<?php session_start(); include("DADB.class.php"); $db=new DADB(); ?> <table border="1" width="100%" cellpadding="0" cellspacing="0"> <tr> <td>代號</td> <td>水果名稱</td> <td>水果價格</td> <td>原產地</td> <td>貨架</td> <td>庫存量</td> <td></td> </tr> <?php $uid=$_SESSION["uid"]; $sql="select * from fruit"; $arr=$db->Query($sql); foreach($arr as $v) { echo"<tr> <td>{$v[0]}</td> // 從數據庫調出我們所需要的內容 <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td><a href='add.php?ids={$v[0]}'>添加</a></td> //這里的購物相當于添加購物車的功能 </tr>"; } ?> <?php //這里顯示的是 購物車有多少產品,和產品的總價格 $ann=array(); if(!empty($_SESSION["gwc"])) { $ann=$_SESSION["gwc"]; } $zhonglei = count($ann); $sum=0; foreach($ann as $k) { $sql1="select price from fruit where ids='{$v[0]}'"; $danjia=$db->Query($sql1); foreach($danjia as $n) { $sum=$sum + $n[0]*$k[1]; } } echo"購物車有<mark>{$zhonglei}</mark>種商品,總價格為<mark>{$sum}</mark>元"; ?> </table> <div> <a href="gouwuche.php" rel="external nofollow" rel="external nofollow" >查看購物車</a> <a href="main.php" rel="external nofollow" rel="external nofollow" >瀏覽商品</a> <a href="zhanghu.php" rel="external nofollow" rel="external nofollow" >查看賬戶</a> </div> </body>
問題解答
回答1:我也想問。。怎么寫
回答2:https://m.php.cn/article/398186.html代碼是在這個網址里的,可以看一下嗎回答3:這個是哪個項目?或者哪個課程? 你直接發出來,樣式很亂,也不知道哪個項目,無法準確回答你的問題
相關文章:
1. 在html文件的目錄下輸入代碼按回車后顯示這個,哪位大佬幫幫我 呀2. 視頻文件不能播放,怎么辦?3. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處4. mysql - jdbc的問題5. node.js - nodejs開發中常用的連接mysql的庫6. mysql replace 死鎖7. mysql - 把一個表中的數據count更新到另一個表里?8. mysql - 如何減少使用或者不用LEFT JOIN查詢?9. javascript - 微信網頁開發從菜單進入頁面后,按返回鍵沒有關閉瀏覽器而是刷新當前頁面,求解決?10. mysql - 字符串根據字典替換
