I'm pretty much done with my shopping cart. I'm able to update the cart,but when I click on the delete button next to the item, it gets redirected to a blank page.
This is the top of my cart.php:
<?php
session_start();
include ("db_connection.php");//include database connection
if (isset($_SESSION['cart'])) {
if(isset($_GET['ebook_id']) && !isset($_POST['update'])){
$statement=$_SESSION['cart'];
$find=false;
$number=0;
for($i=0;$i<count($statement);$i++){
if($statement[$i]['ebook_id']==$_GET['ebook_id']){
$find=true;
$number=$i;
}
}
if($find==true){
$statement[$number]['quantity']=$statement[$number]['quantity']+1;
$_SESSION['cart']=$statement;
}else{
$ebook_title="";
$price=0;
$ebook_image="";
$query=mysqli_query($con,"SELECT * FROM ebooks WHERE ebook_id=".$_GET['ebook_id']);
while ($row=mysqli_fetch_array($query,MYSQLI_ASSOC)) {
$ebook_title=$row['ebook_title'];
$price=$row['price'];
$ebook_image=$row['ebook_image'];
}
$newData=array('ebook_id'=>$_GET['ebook_id'],
'ebook_title'=>$ebook_title,
'price'=>$price,
'ebook_image'=>$ebook_image,
'quantity'=>1);
array_push($statement, $newData);
$_SESSION['cart']=$statement;
}
}
}else{
if(isset($_GET['ebook_id'])){
$ebook_title="";
$ebook_image="";
$price=0;
$query=mysqli_query($con,"SELECT * FROM ebooks WHERE ebook_id=".$_GET['ebook_id']);
while ($row=mysqli_fetch_array($query,MYSQLI_ASSOC)) {
extract ($row);
$ebook_title=$row['ebook_title'];
$ebook_image=$row['ebook_image'];
$price=$row['price'];
}
$statement[]= array('ebook_id' => $_GET['ebook_id'],'ebook_title' => $ebook_title,'ebook_image' => $ebook_image,'price' => $price,'quantity' => 1);
$_SESSION['cart']=$statement;
}
}
?>
This is my cart form:
<form method="POST">
<table class="table">
<thead>
<tr>
<th colspan="2">E-book</th>
<th>Price</th>
<th>Quantity</th>
<th>Subtotal</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
<tr>
<?php
if (isset($_POST['update'])){
$arrquantity=$_POST['quantity'];
//check validate quantity
$valid = 1;
for ($i=0; $i < count($arrquantity); $i++) {
if (!is_numeric($arrquantity[$i]) || $arrquantity[$i] < 1) {
$valid=0;
break;
}
}
if ($valid == 1){
$cart = unserialize (serialize($_SESSION['cart']));
for ($i=0;$i<count($cart);$i++) {
$cart[$i]['quantity']=$arrquantity[$i];
}
}else{
$error= "Quantity is invalid";
}
$_SESSION['cart']=$cart;
}
//delete ebook in cart
$total=0;
if (isset($_SESSION['cart'])) {
$data=$_SESSION['cart'];
$total=0;
for ($i=0;$i<count($data);$i++) {
?>
<?php echo isset($error) ? $error :'';?>
<div class="ebook">
<td><img src="<?php echo $data[$i]['ebook_image'];?>"></td>
<td><?php echo $data[$i]['ebook_title'];?></td>
<td>£<?php echo $data[$i]['price'];?></td>
<td><input type="text" value="<?php echo $data[$i]['quantity'];?>" data-price="<?php echo $data[$i]['price'];?>" data-id="<?php echo $data[$i]['ebook_id'];?>" class="quantity" name="quantity"></td>
<td class="subtotal">£<?php echo $data[$i]['price']*$data[$i]['quantity'];?></td>
<td><i class="fa fa-trash-o"></i>
</div>
</tr>
<?php
$total=($data[$i]['price']*$data[$i]['quantity'])+$total;
}
}else{
echo "<p class='text-muted'>Your shopping cart is empty</p>";
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="5">Total Price</th>
<th colspan="2" id="total">£<?php echo $total; ?></th>
</tr>
</tfoot>
</table>
</div>
<!-- /.table-responsive -->
<div class="box-footer">
<div class="pull-left">
<i class="fa fa-chevron-left"></i>Continue shopping
</div>
<div class="pull-right">
<button type="submit" class="btn btn-default" name="update"><i class="fa fa-refresh"></i>Update</button>
<button type="submit" class="btn btn-primary">Checkout<i class="fa fa-chevron-right"></i>
</button>
</div>
</div>
</form>
Finally, this is the jquery to delete an item:
$(".delete").click(function(e){
e.preventDefault();
var id=$(this).attr('data-id');
$(this).parentsUntil('.ebook').remove();
$.post('./js/delete.php',{
Id:ebook_id
},function(a){
location.href="cart.php?";
});
And the delete.php page to remove the item from the cart session:
<?php
session_start();
$statement=$_SESSION['cart'];
for($i=0;$i<count($statement);$i++){
if($statement[$i]['ebook_id']!=$_POST['ebook_id']){
$newData[]=array(
'ebook_id'=>$statement[$i]['ebook_id'],
'ebook_title'=>$statement[$i]['ebook_title'],
'price'=>$statement[$i]['price'],
'ebook_image'=>$statement[$i]['ebook_image'],
'quantity'=>$statement[$i]['quantity']
);
}
}
if(isset($newData)){
$_SESSION['cart']=$newData;
}else{
unset($_SESSION['cart']);
echo '0';
}
?>
I'm new to ecommerce websites. I would really appreciate any help.
Thanks
On your delete page
<?php
if(isset($_POST['ebook_id'])){
$query=mysqli_query($con,"DELETE FROM ebooks WHERE ebook_id=".$_POST['ebook_id']);
if($query==true) {
return true;
}else {
return false;
}
}
Your JS code should be
$(".delete").click(function(e){
e.preventDefault();
var id=$(this).attr('data-id');
$.ajax({
type:"POST",
url: "delete.php",
data: {ebook_id: id},
}).done(function(data) {
$("#row_"+id+"").hide();
});
});
Your form
<form method="POST">
<table class="table">
<thead>
<tr>
<th colspan="2">E-book</th>
<th>Price</th>
<th>Quantity</th>
<th>Subtotal</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
<?php
if (isset($_POST['update'])){
$arrquantity=$_POST['quantity'];
//check validate quantity
$valid = 1;
for ($i=0; $i < count($arrquantity); $i++) {
if (!is_numeric($arrquantity[$i]) || $arrquantity[$i] < 1) {
$valid=0;
break;
}
}
if ($valid == 1){
$cart = unserialize (serialize($_SESSION['cart']));
for ($i=0;$i<count($cart);$i++) {
$cart[$i]['quantity']=$arrquantity[$i];
}
}else{
$error= "Quantity is invalid";
}
$_SESSION['cart']=$cart;
}
//delete ebook in cart
$total=0;
if (isset($_SESSION['cart'])) {
$data=$_SESSION['cart'];
$total=0;
for ($i=0;$i<count($data);$i++) {
?>
<?php echo isset($error) ? $error :'';?>
//i don't know why you had open div here, so i replaced the div with tr and tr should have been inside the loop
<tr class="ebook" id="row_<?php echo $data[$i]['ebook_id'];?>">
<td><img src="<?php echo $data[$i]['ebook_image'];?>"></td>
<td><?php echo $data[$i]['ebook_title'];?></td>
<td>£<?php echo $data[$i]['price'];?></td>
<td><input type="text" value="<?php echo $data[$i]['quantity'];?>" data-price="<?php echo $data[$i]['price'];?>" data-id="<?php echo $data[$i]['ebook_id'];?>" class="quantity" name="quantity"></td>
<td class="subtotal">£<?php echo $data[$i]['price']*$data[$i]['quantity'];?></td>
<td><i class="fa fa-trash-o"></i>
</tr>
</tr>
<?php
$total=($data[$i]['price']*$data[$i]['quantity'])+$total;
}
}else{
echo "<p class='text-muted'>Your shopping cart is empty</p>";
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="5">Total Price</th>
<th colspan="2" id="total">£<?php echo $total; ?></th>
</tr>
</tfoot>
</table>
</div>
<!-- /.table-responsive -->
<div class="box-footer">
<div class="pull-left">
<i class="fa fa-chevron-left"></i>Continue shopping
</div>
<div class="pull-right">
<button type="submit" class="btn btn-default" name="update"><i class="fa fa-refresh"></i>Update</button>
<button type="submit" class="btn btn-primary">Checkout<i class="fa fa-chevron-right"></i>
</button>
</div>
</div>
Related
I have one table and in this table, I have two button Update and Disable I want to hide those buttons
I trying like this
<table id="example1" class="table table-bordered table-striped table-sm" style=" overflow: auto; ">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php
$hide = 'OFF';
if($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis){?>
<tr>
<td><?php echo $dis->disp_ch_no;?></td>
<td><?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?></td>
<td><?php echo $dis->from_branch_name;?></td>
<td><a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a></td>
<td><a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
</tr>
<?php }?>
</table>
this is my table
How can I hide these buttons
Try this,
<?php
$thswitch = 'OFF';
if($thswitch == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
whenever you want to show just $thswitch = 'ON'; it
You have to check the if () for each row as we did in th. Like:
<table id="example1" class="table table-bordered table-striped table-sm" style="overflow: auto;">
<tr>
<th>Dispatch Challan No</th>
<th>Date</th>
<th>From</th>
<?php $hide = 'OFF';
if ($hide == 'ON') { ?>
<th>Update</th>
<th>Delete</th>
<?php } ?>
</tr>
<?php foreach($dispatch as $dis) { ?>
<tr>
<td> <?php echo $dis->disp_ch_no;?> </td>
<td> <?php echo date("d-m-Y", strtotime($dis->disp_ch_date));?> </td>
<td> <?php echo $dis->from_branch_name;?> </td>
<?php if ($hide == 'ON') { ?>
<td>
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
<td>
<a class="btn btn-danger btn-sm" onclick="delete_dispatch('<?php echo $dis->disp_id; ?>');" title="Click here to delete your Dispatch record"><i class="fa fa-trash" style="color: #fff;"> Disable </i> </a>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
Or by using CSS you can hide this columns as:
Create a CSS class like:
.hidethisColumn { display: none !important; }
Use it in you table as:
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Update</th>
<th class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">Delete</th>
Similarly in rows inside foreach():
<td class="<?=(($hide == 'ON')? 'hidethisColumn' : '')?>">
<a class="btn btn-success btn-sm" href="<?php echo base_url(); ?>booking/dispatch_challan/DispatchChallanController/updateDispatchChallanPage?disp_id=<?php echo $dis->disp_id; ?>"><i class="fa fa-pencil" > Update</i></a>
</td>
I'm trying to work out how to update my shopping cart without updating other products. Should I be working with sessions here or not? MY current issue is that whenever I change the quantity it updates the other products as well and sets the quantity in the box back to 1. How would I go about changing this?
This is what I currently have, I understand why it updates all the products but I can't figure out how to do it otherwise.
<?php
session_start();
include("header.php");
include_once("dbconnect.php");
include("functies.php");
if (empty($_SESSION['cart'])) {
echo "U heeft geen producten in uw winkelwagen";
} else {
$items = $_SESSION['cart'];
$cartitems = explode(",", $items);
?>
<div align="center">
<?php titel(); ?>
<h1 Winkelwagen <h1>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-10 col-md-offset-1">
<table class="table table-hover">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th class="text-center">Price</th>
<th class="text-center">Total</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
$i=1;
foreach ($cartitems as $key=>$id) {
$sql = "SELECT * FROM products WHERE id = $id";
$res=mysqli_query($conn, $sql);
$r = mysqli_fetch_assoc($res);
$sqlb = "SELECT * FROM brewery WHERE code = $r[brewery_code]";
$resb=mysqli_query($conn, $sqlb);
$rb = mysqli_fetch_assoc($resb);
if (isset($_POST['submit'])) {
$amount = $_POST['amount'];
} else $amount = 1;
?>
<tr>
<td class="col-sm-8 col-md-6">
<div class="media">
<img class="thumbnail pull-left" src="Images/<?php echo $r['name'] ?>.jpg" width="85" height="152" alt="..." >
<div class="media-body">
<h4 class="media-heading"><?php echo $r['name']; ?></h4>
<h5 class="media-heading"> by <?php echo $rb['name'];; ?></a></h5>
<span>Status: </span><span class="text-success"><strong>In Stock</strong></span>
</div>
</div></td>
<td class="col-sm-1 col-md-1" style="text-align: center">
<form action="" method="post">
<input type="number" class="form-control" name="amount" value="1" min="1">
<input type="submit" name="submit" class="btn btn-primary btn-sm">
</form>
</td>
<?php
$total = $total + $r['price'];
$i++;
$producttotal = $amount * $r['price'];
?>
<td class="col-sm-1 col-md-1 text-center"><strong>€ <?php echo number_format($r['price'],2);?> </strong></td>
<td class="col-sm-1 col-md-1 text-center"><strong>€ <?php echo number_format($producttotal,2);?> </strong></td>
<td class="col-sm-1 col-md-1">
<button type="button" class="btn btn-danger">
Verwijderen
</button></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h5>Subtotal<br>Estimated shipping</h5><h3>Total</h3></td>
<td class="text-right"><h5><strong>$24.59<br>$6.94</strong></h5><h3>$31.53</h3></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>
<button type="button" class="btn btn-primary"> Continue Shopping </button></td>
<td>
<button type="button" class="btn btn-primary"> Checkout </button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<?php } ?>
Your form needs to contain an indicator for which product you want to increase the quantity. For example, like this:
<form action="" method="post">
<input type="number" class="form-control" name="amount[<?php echo $id;?>]" value="1" min="1">
<input type="submit" name="submit" class="btn btn-primary btn-sm">
</form>
You can then evaluate the id like this:
if (isset($_POST['submit']) && isset($_POST['amount'][$id])) {
$amount = $_POST['amount'][$id];
} else {
$amount = 1;
}
I don't understand why you would set the amount to 1 if it hasn't be set in the $_POST. I think you have to store the amount per product in the session, not just the ids as you are doing now.
Maybe like this:
if (isset($_POST['submit']) && isset($_POST['amount'][$id])) {
$amount = intval($_POST['amount'][$id]);
} else {
if(isset($_SESSION['amounts'][$id])) {
$amount = $_SESSION['amounts'][$id];
} else {
$amount = 1;
}
}
if(!isset($_SESSION['amounts'])) $_SESSION['amounts'] = array();
$_SESSION['amounts'][$id] = $amount;
Here is the code for notification code:
<?php if(isset($notification) && $notification->result() >0 ){?>
<div class="panel-heading pull-right col-md-6"
style="height:140px; margin-top:-140px; background-color:white; overflow-y: scroll;">
<h5><strong>Student with 3 Consecutive Absences</strong></h5>
<table class="table">
<thead>
<th>Course Code-Section</th>
<th>Student Name</th>
<th>View</th>
</thead>
<tbody>
<?php foreach($notification->result() as $notif)
{
if($notif->Total >=3)
{
?>
<tr>
<td><?php echo $notif->Course_Code_Section?</td>
<td><?php echo $notif->Student?></td>
<td>
<form action="<?php echo base_url();?>index.php/attendance/check" method="post" target="_blank">
<input type="hidden" name="CID" value="<?php echo $notif->CID;?>">
<button class="btn btn-xs btn-success"><i class="icon-eye-open"></i> View</button>
<?php echo form_close();?>
</td>
</tr>
</div>
<?php }?>
<?php }?>
</tbody>
</table>
</div>
<?php }?>
Here is the notification view, the default background color is white. Therefore, I want it to make the background color red when the condition met.
Try this:
<?php
$style = '';
if(isset($notification) && $notification->result() > 0 )
{
$style = 'style="color:red"';
// Put your css style property here
}
?>
Html:
<div <?php echo $style ?>>
</div>
You can do as -
<?php
if(your condition)
{
?>
<style>
#your_div
{
background:red !important;
}
</style>
<?php
}
else
{
?>
<style>
#your_div
{
background:white !important;
}
</style>
<?php
}
?>
If your condition is true in PHP you can just this line in your tag:
<tr bgcolor="#FF0000">
I don't know if my html code will appear or not. Please refer this site:
https://www.w3schools.com/tags/att_tr_bgcolor.asp
Please try this code ,i hope this is your condition
<?php
$bcolor ='background-color:white';
if(isset($notification) && $notification->result() >0 ){
$bcolor ='background-color:white';
}?>
<div class="panel-heading pull-right col-md-6"
style="height:140px; margin-top:-140px; <?php echo $bcolor ;?> overflow-y: scroll;">
<h5><strong>Student with 3 Consecutive Absences</strong></h5>
<table class="table">
<thead>
<th>Course Code-Section</th>
<th>Student Name</th>
<th>View</th>
</thead>
<tbody>
<?php foreach($notification->result() as $notif)
{
if($notif->Total >=3)
{
?>
<tr>
<td><?php echo $notif->Course_Code_Section?</td>
<td><?php echo $notif->Student?></td>
<td>
<form action="<?php echo base_url();?>index.php/attendance/check" method="post" target="_blank">
<input type="hidden" name="CID" value="<?php echo $notif->CID;?>">
<button class="btn btn-xs btn-success"><i class="icon-eye-open"></i> View</button>
<?php echo form_close();?>
</td>
</tr>
</div>
<?php }?>
<?php }?>
</tbody>
</table>
</div>
try
<?php
$bg_red = '';
if (condition) {
$bg_red = '<style="background-color: red;">';
}
?>
<tr <php? echo $bg_red; ?>>
<td></td>
<td></td>
<td></td>
</tr>
hi all my name is Fadil Raditya
i am stuck in some code in php. I really need help.
i want add item in chart from selected item how ever it can not increment.
this is some of my code.
<?php session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_GET["action"])) {
switch($_GET["action"]) {
case "add":
if(!empty($_POST["quantity"])) {
$productByCode = $db_handle->runQuery("SELECT * FROM tblproduct WHERE code='" . $_GET["code"] . "'");
$itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 'code'=>$productByCode[0]["code"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"]));
if(!empty($_SESSION["cart_item"])) {
if(in_array($productByCode[0]["code"],$_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($productByCode[0]["code"] == $k)
{
$_SESSION["cart_item"][$k]["quantity"] = $_POST["quantity"];
}
}
}
else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
and i want call adding the quantity when hit the add chart button
<?php
$product_array = $db_handle->runQuery("SELECT * FROM tblproduct ORDER BY id DESC");
if (!empty($product_array)) {
foreach($product_array as $key=>$value){
?>
<div class="col-xs-6 col-sm-3 col-md-3">
<div class="team-wrapper-big">
<form method="post" action="index.php?action=add&code=<?php echo $product_array[$key]["code"]; ?>">
<h6><?php echo $product_array[$key]["name"]; ?></h6>
<img src="<?php echo $product_array[$key]["image"]; ?>">
<?php echo "Rp ".$product_array[$key]["price"]; ?>
<hr>
<img src="img/VIEW.png">
<input type="text" name="quantity" value="1" placeholder="quantity in number" />
<input type="submit" value="Add to cart" class="btnAddAction" src="img/BUY.png">
<hr>
</form>
</div>
</div>
<?php
}
}
?>
This is the ouput source
<div id="shopping-cart">
<div class="txt-heading"></div>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?><center>
<table cellpadding="10" cellspacing="3" border="1">
<tbody>
<tr>
<th><strong>Name</strong></th>
<th><strong>Code</strong></th>
<th><strong>Quantity</strong></th>
<th><strong>Price</strong></th>
<th><strong>Total Price</strong></th>
<th><strong>Action</strong></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td><strong><?php echo $item["name"]; ?></strong></td>
<td><?php echo $item["code"]; ?></td>
<td><?php echo $item["quantity"]; ?></td>
<?php $_SESSION["track"] = $item["quantity"]; ?>
<td align=right><?php echo "Rp. ".$item["price"]; ?></td>
<td align=right><?php echo "Rp. ".$item["quantity"]*$item["price"]; ?></td>
<td>Remove Item</td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
<tr>
<td colspan="6" align=right><strong>Total:</strong> <?php echo "Rp. ".$item_total; ?></td>
</tr>
</tbody>
</table> </center>
<?php
}
?><a id="btnEmpty" href="index.php?action=empty">Empty Cart</a>
</div>
i hope anyone can help me. need suggestion and solution. open to discussion.
regards
Fadil Raditya
Im trying to build an ap in php to learn foreign languages. I got an function in it that builds a form and starts the test. it looks like:
public function test($pol_ang)
{
$words = $this->wordsArray();
if($pol_ang == 1)
{
$_SESSION['correctAnswers'] = $this->answersPolAng($words);
}else {$_SESSION['correctAnswers'] = $this->answersAngPol($words);}
if(isset($_POST['btn-confirm']))
{
$answer = strip_tags($_POST['txt_word']);
if($answer != "")
{
$_SESSION['usersAnswerArray'][$_SESSION['licznik']-1] = $answer;
$_SESSION['licznik']++;
}
if($_SESSION['licznik'] > count($words))
{
unset($_SESSION['licznik']);
$this->auth_user->redirect('result.php');
}
}
if(empty($_SESSION['licznik']))
{
$_SESSION['licznik'] = 1;
}
?>
<form method="post" class="form-signin">
<table class="table table-striped table-hover">
<thead>
<tr>
<th><?php echo $_SESSION['licznik'].' z '.count($words); ?></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<?php
$word = explode(";",$words[($_SESSION['licznik']-1)]);
if($pol_ang == 1)
{
?>
<td><?php echo $word[0]; ?></td>
<?php
}
else
{
?>
<td><?php echo $word[1]; ?></td>
<?php
}
?>
<td>-</td>
<td>
<div class="form-group">
<input type="text" class="form-control" name="txt_word" placeholder="Tłumaczenie" required />
<span id="check-e"></span>
</div>
</td>
</tr>
</tbody>
</table>
<hr />
<div class="form-group">
<button type="submit" name="btn-confirm" class="btn btn-default">
<i class="glyphicon glyphicon-log-in"></i> END
</button>
</div>
</form>
<?php
}
At the begginning wordsArray() function explode class's variable and $words becomes an array: [0]->wordLanguage1;wordLanguage2, [1]->wordLanguage1;wordLanguage2 etc...
$pol_ang is language option. If equals 1 then $_SESSION['correctAnswers'] becomes "wordsLanguage1", if equals 0 then becomes "wordLanguage2".
This function works fine. But what I wanna do is that my functio after ending the test should repeat asking for words that user entered incorrect. I can not find the solution to my problem