🔒 Closed --mga boss patulong naman po

Status
Not open for further replies.

Netflix

Forum Veteran
upload_2017-3-13_15-54-5.webp

Yan kasi kapag first na pag open ko ng system ko kapag nag lalagay ako ng quantity hindi sya nag da direct sa next action nya which is dapat sya ma add sa cart..


upload_2017-3-13_15-57-9.webp


pero kapag binalick ko sa previous page .. na add na sya..then kapag nag add ako ulit ng ibang item nag dadirect na sya......

Code:
Eto yung sa form


  <form method="post" action="shop.php?action=add&id= <?php echo $row["id"]; ?>">
            <div style="border: 1px solid #eaeaec; margin: -1px 19px 3px -1px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); padding:10px;" align="center" >
            <img src="<?php echo $row["image"]; ?>" class="img-responsive">
            <h5 class="text-info"><?php echo $row["p_name"]; ?></h5>
            <h5 class="text-default">Description:<?php echo $row["description"]; ?>
            <h5 class="text-danger">Php<?php echo $row["price"]; ?></h5></h5>
            <input type="text" name="quantity" class="form-control" value="" placeholder="Enter Quantity">
            <script>
                if (quantity)
            </script>
            <input type="hidden" name="hidden_name" value="<?php echo $row["p_name"]; ?>">
            <input type="hidden" name="hidden_price" value="<?php echo $row["price"]; ?>">
            <input type="submit" name="add" style="margin-top:5px;" class="btn btn-warning" value="Add to Cart">
            <!--Another row of camsss-->

            </div>
            </form>
            </div>



            <!---->





            <?php
        }
    }
    ?>
    <div style="clear:both"></div>
    <h2>Your Orders</h2>
    <div class="table-responsive">
    <table class="table table-bordered">
    <tr>
    <th width="40%">Product Name</th>
    <th width="10%">Quantity</th>
    <th width="20%">Price Details</th>
    <th width="15%">Order Total</th>
    <th width="5%">Action</th>
    </tr>
    <?php
    if(!empty($_SESSION["cart"]))
    {
        $total = 0;
        foreach($_SESSION["cart"] as $keys => $values)
        {
            ?>
            <tr>
            <td> <?php echo $values["item_name"]; ?></td>
            <td>  <?php echo $values["item_quantity"] ?></td>
            <td><?php echo $values["product_price"]; ?></td>
            <td><?php echo number_format($values["item_quantity"] * $values["product_price"], 2); ?></td>
            <td><a href="shop.php?action=delete&id=<?php echo $values["product_id"]; ?>"><span class="text-danger"><i class="glyphicon glyphicon-trash "></i></span></a></td>
            </tr>
            <?php
            $total = $total + ($values["item_quantity"] * $values["product_price"]);
        }
        ?>
        <tr>
        <td colspan="3" align="right">Total</td>
        <td align="right"><h4 class="text-danger">Php <?php echo number_format($total, 2); ?></h4></td>
        <td></td>
        </tr>

Code:
ito yung sa shop.php ko

<?php
session_start();
$connect = mysqli_connect("localhost", "root", "", "camshop");
if(isset($_POST["add"]))
{
    if(isset($_SESSION["cart"]))
    {
        $item_array_id = array_column($_SESSION["cart"], "product_id");
        if(!in_array($_GET["id"], $item_array_id))
        {
            $count = count($_SESSION["cart"]);
            $item_array = array(
            'product_id' => $_GET["id"],
            'item_name' => $_POST["hidden_name"],
            'product_price' => $_POST["hidden_price"],
            'item_quantity' => $_POST["quantity"]
            );
            $_SESSION["cart"][$count] = $item_array;
            echo '<script>window.location="index.php"</script>';
        }
        else
        {
            echo '<script>alert("Items already added to cart")</script>';
            echo '<script>window.location="index.php"</script>';
        }
    }
    else
    {
        $item_array = array(
        'product_id' => $_GET["id"],
        'item_name' => $_POST["hidden_name"],
        'product_price' => $_POST["hidden_price"],
        'item_quantity' => $_POST["quantity"]
        );
        $_SESSION["cart"][0] = $item_array;
    }
}
if(isset($_GET["action"]))
{
    if($_GET["action"] == "delete")
    {
        foreach($_SESSION["cart"] as $keys => $values)
        {
            if($values["product_id"] == $_GET["id"])
            {
                unset($_SESSION["cart"][$keys]);
                echo '<script>alert("Product has been removed")</script>';
                echo '<script>window.location="index.php"</script>';
            }
        }
    }
}
?>


upload_2017-3-13_16-3-13.webp
 
nasaan ba yung cart mo? sa index.php ba? ..kasi sabi mo pag nag back sa previous page which is index.php eh nag add na sa cart. tama ba? so wala siya sa shop.php ..try mo gawing form action=index.php tapos yung php script ilagay mo sa pinaka unang line
 
nasaan ba yung cart mo? sa index.php ba? ..kasi sabi mo pag nag back sa previous page which is index.php eh nag add na sa cart. tama ba? so wala siya sa shop.php ..try mo gawing form action=index.php tapos yung php script ilagay mo sa pinaka unang line
Ayaw po eh.. nag lilink lang sya sa index pero yung action hindi na apply
 
ilagay mo sa unahan ng index.php yan. kasi diba sa form action pinalitan mo ng index.php ..so pagka load ng index.php irurun nya yung php script mo para makuha yung inadd na item
you mean i cocopy ko po yung laman ng shop.php ko at ilalagay sa index.php??
 
yes po..sa line 1 ng index.php
Ok po salamat try ko po mamaya..
pwede po pahabol?
pano po mag lagay ng input na text dapat sa taas dapat mag start yung tinatype mo at hindi mag overlapped sa input box,
yung parang my scrollbar po pano po ba yun na ang hirap po di ko alam attribute nun
upload_2017-3-13_17-41-58.webp


alam nyu po ibig sabihin ..tingnan mo po yung specifications input ko..
 
Ok po salamat try ko po mamaya..
pwede po pahabol?
pano po mag lagay ng input na text dapat sa taas dapat mag start yung tinatype mo at hindi mag overlapped sa input box,
yung parang my scrollbar po pano po ba yun na ang hirap po di ko alam attribute nun
View attachment 145459

alam nyu po ibig sabihin ..tingnan mo po yung specifications input ko..

di ko ma gets yung hindi mag ooverlapped na part...try mo yung textarea tag
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 15
    Replies
  • 1K
    Views
  • 3
    Participants
Last reply from:
LordRein

Trending Topics

Online now

Members online
1,081
Guests online
1,186
Total visitors
2,267

Forum statistics

Threads
2,273,926
Posts
28,952,459
Members
1,234,993
Latest member
skatstip
Back
Top