2017-04-12 28 views
0

其他網頁我嘗試了很多事情,但我的引導按鈕沒有重定向到其他頁面即viewcart.php引導按鈕不重定向到

<button id="cc" class="btn btn-success btn-lg" style="float: right;" ><span class="glyphicon glyphicon-shopping-cart"></span> <span class="items"> 
     <?php 

    include 'connection.php'; 
    $z=$_SESSION["user_id"]; 
    $pp=mysql_query("SELECT count(item) from cart where cust_id=$z"); 
    $row = mysql_fetch_assoc($pp); 
    echo $row['count(item)']; 
    ?></span></button> 

    <script type="text/javascript"> 

document.getElementById("cc").onclick = function() { 
    location.href = "viewcart.php"; 
    }; </script> 
+0

JavaScript的工作好的,用php檢查HTML輸出的posibbles代碼錯誤。代碼的作品沒有php – Roy

+0

我想寫在按鈕內的總項目數。所以你能告訴我怎麼寫 – tom

回答

0

試試這個:

$pp=mysql_query("SELECT count(item) as item from cart where cust_id=$z"); 
$row = mysql_fetch_assoc($pp); 
echo $row['item'];