Php na mysqli msaada tafadhali nashida kubwa

Srebrina

JF-Expert Member
Jan 28, 2012
944
405
Habarini wana jamvi

shida yangu ni kwamba nina website natengeneza lakini shida ni kwamba code za kufuta au kuremove product kwenye cart zinagoma kufunction na button aifanyi kazi msaada wanajamvi juu ya hili website ni hii Easy Business

na code ni hizi



Code:
<!DOCTYPE>
<?php
include("functions/functions.php");
?>
<html>
    <head>
        <title>Easy Business</title>
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html">
        <meta name="author" content="Jake Rocheleau">
        <link rel="shortcut icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
        <link rel="stylesheet" href="styles/style.css" media="all" />
    </head>
    
<body>

    <div class="main_wrapper">
    

        <div class="header_wrapper">
        
            <a href="index.php"><img id="logo" src="images/logo.png"/></a>
        
        </div>
        
        <div class="menubar">
        
            <ul id="menu">
                <li><a href="index.php">Home</a></li>
                <li><a href="all_products.php">All Products</a></li>
                <li><a href="customer/my_account.php">My Account</a></li>
                <li><a href="#">Sign Up</a></li>
                <li><a href="cart.php">Shopping Cart</a></li>
                <li><a href="#">Contact Us</a></li>
            </ul>
            
            <div id="form">
                <form method="get" action="results.php" enctype="multipart/form-data">
                    <input type="text" name="user_query" placeholder="Search a Product" />
                    <input type="submit" name="search" value="Search" />
                </form>
            </div>
            
        </div>
        
        <div class="content_wrapper">
        
        <div id="sidebar">
            <div id="sidebar_title" align="left">Categories</div>
            
            <ul id="cats">
                <?php getCats(); ?>
            </ul>
            
            <div id="sidebar_title" align="left">Brands</div>
            
            <ul id="cats">
                <?php getBrands(); ?>
            </ul>
        
        </div>
        
        <div id="content_area">
        <?php cart(); ?>
        <div id="shopping_cart">
            <form action="insert_product.php" method="post" enctype="multipart/form-data">
            <table align="center" width="790" border="2" bgcolor="#70389C">
                <tr align="center">
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Welcome Guest! </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">You have <u><?php total_items();?></u> Items</span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Total Price <?php total_price(); ?> </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white"><a href="cart.php" style="text-decoration:none; color:white;">Go to Buy</a> </span></td>
                </tr>
            </table>
            </form>
        </div>   
        
            <div id="products_box">
                
                <div id="w">
    <header id="title">
      <h1>Your Products Shopping Cart</h1>
    </header>
    <div id="page">
      <table id="cart">
        <thead>
          <tr>
            <th class="first">Photo</th>
            <th class="second">Quantity</th>
            <th class="third">Product (s)</th>
            <th class="fourth">Line Total</th>
            <th class="fifth">Remove</th>
          </tr>
        </thead>
    <?php
        
    $total = 0;
    
    global $connection;
    
    $ip = getIp();
    
    $sel_price = "select * from cart where ip_add='$ip'";
    
    $run_price = mysqli_query($connection, $sel_price);
    
    while($p_price=mysqli_fetch_array($run_price)){
        
        $pro_id = $p_price['p_id'];
        
        $pro_price = "select * from products where product_id='$pro_id'";
        
        $run_pro_price = mysqli_query($connection, $pro_price);
        
        while ($pp_price = mysqli_fetch_array($run_pro_price)){
        
        $product_price = $pp_price['product_price'];
        
        $product_title = $pp_price['product_title'];
        
        $product_image = $pp_price['product_image'];
        
        $single_price = $pp_price['product_price'];
        
        $values = $product_price;
        
        $total += $values;
    ?>
        <tbody>
          <!-- shopping cart contents -->
          <tr class="productitm">
            <!-- http://www.inkydeals.com/deal/ginormous-bundle/ -->
            <td><img src="admin_area/product_images/<?php echo $product_image; ?>" width="120" height="70" class="thumb" /></td>
            <td><input type="number" value="1" min="0" max="99" class="qtyinput" name="qty"></td>
            <td><?php echo $product_title; ?></td>
            <td><?php echo "Tsh : " . $single_price; ?></td>
            <td><input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?>"/></td>
          </tr>
    <?php }} ?>
          <!-- tax + subtotal -->
          <tr class="extracosts">
            <td class="light"><input type="submit" name="update_cart" value="Update Cart"/></td>
            <td colspan="2" class="light"></td>
            <td><input type="submit" name="continue" value="Continue Shopping"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr class="totalprice">
            <td class="light">Total:</td>
            <td colspan="2">&nbsp;</td>
            <td colspan="2"><span class="thick"><?php echo "Tsh : " . $total ?></span></td>
          </tr>
          
          <!-- checkout btn -->
          <tr class="checkoutrow">
            <td colspan="5" class="checkout"><button id="submitbtn"><a href="checkout.php" style="text-decoration:none; color:black; ">Checkout Now!</a></button></td>
          </tr>
        </tbody>
      </table>
      <?php
      
        $ip = getIp();
      
        if(isset($_POST['update_cart'])){
            
            foreach($_POST['remove'] as $remove_id){
                
            $delete_product = "delete from cart where p_id='$remove_id' AND ip_add='$ip'";

            $run_delete = mysqli_query($connection, $delete_product);
            
            if($run_delete){
                
                echo "<script>window.open('cart.php','_self')</script>";
                
            }
                
            }
            
        }
      
      ?>
    </div>
  </div>
                
                
            </div>
        </div>
        </div>
        <div id="footer">
        <h2 style="text-align:center; padding-top:10px;">&copy; 2017 by Proto Network</h2>
        </div>

    </div>

</body>
</html>


Untitled1.jpg


nimekosea wapi jamani
 
Habarini wana jamvi

shida yangu ni kwamba nina website natengeneza lakini shida ni kwamba code za kufuta au kuremove product kwenye cart zinagoma kufunction na button aifanyi kazi msaada wanajamvi juu ya hili website ni hii Easy Business

na code ni hizi



Code:
<!DOCTYPE>
<?php
include("functions/functions.php");
?>
<html>
    <head>
        <title>Easy Business</title>
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html">
        <meta name="author" content="Jake Rocheleau">
        <link rel="shortcut icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
        <link rel="stylesheet" href="styles/style.css" media="all" />
    </head>
   
<body>

    <div class="main_wrapper">
   

        <div class="header_wrapper">
       
            <a href="index.php"><img id="logo" src="images/logo.png"/></a>
       
        </div>
       
        <div class="menubar">
       
            <ul id="menu">
                <li><a href="index.php">Home</a></li>
                <li><a href="all_products.php">All Products</a></li>
                <li><a href="customer/my_account.php">My Account</a></li>
                <li><a href="#">Sign Up</a></li>
                <li><a href="cart.php">Shopping Cart</a></li>
                <li><a href="#">Contact Us</a></li>
            </ul>
           
            <div id="form">
                <form method="get" action="results.php" enctype="multipart/form-data">
                    <input type="text" name="user_query" placeholder="Search a Product" />
                    <input type="submit" name="search" value="Search" />
                </form>
            </div>
           
        </div>
       
        <div class="content_wrapper">
       
        <div id="sidebar">
            <div id="sidebar_title" align="left">Categories</div>
           
            <ul id="cats">
                <?php getCats(); ?>
            </ul>
           
            <div id="sidebar_title" align="left">Brands</div>
           
            <ul id="cats">
                <?php getBrands(); ?>
            </ul>
       
        </div>
       
        <div id="content_area">
        <?php cart(); ?>
        <div id="shopping_cart">
            <form action="insert_product.php" method="post" enctype="multipart/form-data">
            <table align="center" width="790" border="2" bgcolor="#70389C">
                <tr align="center">
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Welcome Guest! </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">You have <u><?php total_items();?></u> Items</span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Total Price <?php total_price(); ?> </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white"><a href="cart.php" style="text-decoration:none; color:white;">Go to Buy</a> </span></td>
                </tr>
            </table>
            </form>
        </div>  
       
            <div id="products_box">
               
                <div id="w">
    <header id="title">
      <h1>Your Products Shopping Cart</h1>
    </header>
    <div id="page">
      <table id="cart">
        <thead>
          <tr>
            <th class="first">Photo</th>
            <th class="second">Quantity</th>
            <th class="third">Product (s)</th>
            <th class="fourth">Line Total</th>
            <th class="fifth">Remove</th>
          </tr>
        </thead>
    <?php
       
    $total = 0;
   
    global $connection;
   
    $ip = getIp();
   
    $sel_price = "select * from cart where ip_add='$ip'";
   
    $run_price = mysqli_query($connection, $sel_price);
   
    while($p_price=mysqli_fetch_array($run_price)){
       
        $pro_id = $p_price['p_id'];
       
        $pro_price = "select * from products where product_id='$pro_id'";
       
        $run_pro_price = mysqli_query($connection, $pro_price);
       
        while ($pp_price = mysqli_fetch_array($run_pro_price)){
       
        $product_price = $pp_price['product_price'];
       
        $product_title = $pp_price['product_title'];
       
        $product_image = $pp_price['product_image'];
       
        $single_price = $pp_price['product_price'];
       
        $values = $product_price;
       
        $total += $values;
    ?>
        <tbody>
          <!-- shopping cart contents -->
          <tr class="productitm">
            <!-- http://www.inkydeals.com/deal/ginormous-bundle/ -->
            <td><img src="admin_area/product_images/<?php echo $product_image; ?>" width="120" height="70" class="thumb" /></td>
            <td><input type="number" value="1" min="0" max="99" class="qtyinput" name="qty"></td>
            <td><?php echo $product_title; ?></td>
            <td><?php echo "Tsh : " . $single_price; ?></td>
            <td><input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?>"/></td>
          </tr>
    <?php }} ?>
          <!-- tax + subtotal -->
          <tr class="extracosts">
            <td class="light"><input type="submit" name="update_cart" value="Update Cart"/></td>
            <td colspan="2" class="light"></td>
            <td><input type="submit" name="continue" value="Continue Shopping"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr class="totalprice">
            <td class="light">Total:</td>
            <td colspan="2">&nbsp;</td>
            <td colspan="2"><span class="thick"><?php echo "Tsh : " . $total ?></span></td>
          </tr>
         
          <!-- checkout btn -->
          <tr class="checkoutrow">
            <td colspan="5" class="checkout"><button id="submitbtn"><a href="checkout.php" style="text-decoration:none; color:black; ">Checkout Now!</a></button></td>
          </tr>
        </tbody>
      </table>
      <?php
     
        $ip = getIp();
     
        if(isset($_POST['update_cart'])){
           
            foreach($_POST['remove'] as $remove_id){
               
            $delete_product = "delete from cart where p_id='$remove_id' AND ip_add='$ip'";

            $run_delete = mysqli_query($connection, $delete_product);
           
            if($run_delete){
               
                echo "<script>window.open('cart.php','_self')</script>";
               
            }
               
            }
           
        }
     
      ?>
    </div>
  </div>
               
               
            </div>
        </div>
        </div>
        <div id="footer">
        <h2 style="text-align:center; padding-top:10px;">&copy; 2017 by Proto Network</h2>
        </div>

    </div>

</body>
</html>


View attachment 451765

nimekosea wapi jamani


mbona kimya wadau
 
Habarini wana jamvi

shida yangu ni kwamba nina website natengeneza lakini shida ni kwamba code za kufuta au kuremove product kwenye cart zinagoma kufunction na button aifanyi kazi msaada wanajamvi juu ya hili website ni hii Easy Business

na code ni hizi



Code:
<!DOCTYPE>
<?php
include("functions/functions.php");
?>
<html>
    <head>
        <title>Easy Business</title>
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html">
        <meta name="author" content="Jake Rocheleau">
        <link rel="shortcut icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="icon" href="http://spyrestudios.com/favicon.ico">
        <link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
        <link rel="stylesheet" href="styles/style.css" media="all" />
    </head>
   
<body>

    <div class="main_wrapper">
   

        <div class="header_wrapper">
       
            <a href="index.php"><img id="logo" src="images/logo.png"/></a>
       
        </div>
       
        <div class="menubar">
       
            <ul id="menu">
                <li><a href="index.php">Home</a></li>
                <li><a href="all_products.php">All Products</a></li>
                <li><a href="customer/my_account.php">My Account</a></li>
                <li><a href="#">Sign Up</a></li>
                <li><a href="cart.php">Shopping Cart</a></li>
                <li><a href="#">Contact Us</a></li>
            </ul>
           
            <div id="form">
                <form method="get" action="results.php" enctype="multipart/form-data">
                    <input type="text" name="user_query" placeholder="Search a Product" />
                    <input type="submit" name="search" value="Search" />
                </form>
            </div>
           
        </div>
       
        <div class="content_wrapper">
       
        <div id="sidebar">
            <div id="sidebar_title" align="left">Categories</div>
           
            <ul id="cats">
                <?php getCats(); ?>
            </ul>
           
            <div id="sidebar_title" align="left">Brands</div>
           
            <ul id="cats">
                <?php getBrands(); ?>
            </ul>
       
        </div>
       
        <div id="content_area">
        <?php cart(); ?>
        <div id="shopping_cart">
            <form action="insert_product.php" method="post" enctype="multipart/form-data">
            <table align="center" width="790" border="2" bgcolor="#70389C">
                <tr align="center">
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Welcome Guest! </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">You have <u><?php total_items();?></u> Items</span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white">Total Price <?php total_price(); ?> </span></td>
                    <td colspan="3"><span style="float:center; font-size:18px; padding:5px; line-height:40px;"><b style="color:white"><a href="cart.php" style="text-decoration:none; color:white;">Go to Buy</a> </span></td>
                </tr>
            </table>
            </form>
        </div>  
       
            <div id="products_box">
               
                <div id="w">
    <header id="title">
      <h1>Your Products Shopping Cart</h1>
    </header>
    <div id="page">
      <table id="cart">
        <thead>
          <tr>
            <th class="first">Photo</th>
            <th class="second">Quantity</th>
            <th class="third">Product (s)</th>
            <th class="fourth">Line Total</th>
            <th class="fifth">Remove</th>
          </tr>
        </thead>
    <?php
       
    $total = 0;
   
    global $connection;
   
    $ip = getIp();
   
    $sel_price = "select * from cart where ip_add='$ip'";
   
    $run_price = mysqli_query($connection, $sel_price);
   
    while($p_price=mysqli_fetch_array($run_price)){
       
        $pro_id = $p_price['p_id'];
       
        $pro_price = "select * from products where product_id='$pro_id'";
       
        $run_pro_price = mysqli_query($connection, $pro_price);
       
        while ($pp_price = mysqli_fetch_array($run_pro_price)){
       
        $product_price = $pp_price['product_price'];
       
        $product_title = $pp_price['product_title'];
       
        $product_image = $pp_price['product_image'];
       
        $single_price = $pp_price['product_price'];
       
        $values = $product_price;
       
        $total += $values;
    ?>
        <tbody>
          <!-- shopping cart contents -->
          <tr class="productitm">
            <!-- http://www.inkydeals.com/deal/ginormous-bundle/ -->
            <td><img src="admin_area/product_images/<?php echo $product_image; ?>" width="120" height="70" class="thumb" /></td>
            <td><input type="number" value="1" min="0" max="99" class="qtyinput" name="qty"></td>
            <td><?php echo $product_title; ?></td>
            <td><?php echo "Tsh : " . $single_price; ?></td>
            <td><input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?>"/></td>
          </tr>
    <?php }} ?>
          <!-- tax + subtotal -->
          <tr class="extracosts">
            <td class="light"><input type="submit" name="update_cart" value="Update Cart"/></td>
            <td colspan="2" class="light"></td>
            <td><input type="submit" name="continue" value="Continue Shopping"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr class="totalprice">
            <td class="light">Total:</td>
            <td colspan="2">&nbsp;</td>
            <td colspan="2"><span class="thick"><?php echo "Tsh : " . $total ?></span></td>
          </tr>
         
          <!-- checkout btn -->
          <tr class="checkoutrow">
            <td colspan="5" class="checkout"><button id="submitbtn"><a href="checkout.php" style="text-decoration:none; color:black; ">Checkout Now!</a></button></td>
          </tr>
        </tbody>
      </table>
      <?php
     
        $ip = getIp();
     
        if(isset($_POST['update_cart'])){
           
            foreach($_POST['remove'] as $remove_id){
               
            $delete_product = "delete from cart where p_id='$remove_id' AND ip_add='$ip'";

            $run_delete = mysqli_query($connection, $delete_product);
           
            if($run_delete){
               
                echo "<script>window.open('cart.php','_self')</script>";
               
            }
               
            }
           
        }
     
      ?>
    </div>
  </div>
               
               
            </div>
        </div>
        </div>
        <div id="footer">
        <h2 style="text-align:center; padding-top:10px;">&copy; 2017 by Proto Network</h2>
        </div>

    </div>

</body>
</html>


View attachment 451765

nimekosea wapi jamani


Sijaona sehemu uliyofunga form
 
Ngumu sana kupata msaada hapa bila kuona what's happening kwenye system yenyewe aisee
 

Similar Discussions

Back
Top Bottom