Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php while($row=mysqli_fetch_array($result)) { ?>
- <div id="item">
- <form method="post" action="cartReceiver.php">Quantity:
- <?php echo '<img height="200" width="200" src="data:image;base64,'.$row[2]. '">';?>
- </br>
- <?php echo $row[ "name"];?>
- </br>
- <?php echo $row[ "price"];?>
- </br>
- <?php echo $row[ "description"];?>
- </br>
- <input type="text" value="" name="quantity" />
- </br>
- <input type="submit" value="add to cart" name="cart" />
- </form>
- </div>
- <?php }//end of while ?>
- <?php
- if (isset($_POST[ "cart"])){
- $addtoname=$_SESSION[ 'username'];
- $addtoprice=$row[ 'price'];
- $addtodiscount=$row[ 'discount'];
- $addtoid=$row[ 'id'];
- $addtoimage=$row[ 'image'];
- $addtoquantity=$_POST[ 'quantity'];
- $hostname="localhost" ;
- $username="root";
- $password="" ;
- $database="myproject" ; $con=mysqli_connect($hostname,$username,$password,$database) or die(mysqli_error());
- $select=mysqli_select_db($con, "myproject")or die( "cannnot select db"); mysqli_query($con,"INSERT INTO cart(username,quantity,price,image,id,discount) VALUES('$addtoname','$addtoquantity','$addtoprice','$addtoimage','$addtoid','$addtodiscount')");
- echo "success";
- }
- else{
- echo "fail";
- }
- <?php while($row=mysqli_fetch_array($result)) { ?>
- <div id="item">
- <form method="post" action="cartReceiver.php">Quantity:
- <?php echo '<img height="200" width="200" src="data:image;base64,'.$row[2]. '">';?>
- </br>
- <input type="text" name="name" value=" <?php echo $row[ "name"];?>" readonly />
- </br>
- <input type="text" name="price" value="<?php echo $row[ "price"];?>" readonly />
- </br>
- <input type="text" name="description" value="<?php echo $row[ "description"];?>" readonly />
- </br>
- <input type="text" value="" name="quantity" />
- </br>
- <input type="submit" value="add to cart" name="cart" />
- </form>
- </div>
- <?php }//end of while ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement