Click here to Skip to main content
15,886,782 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi i have a problem with my shopiing cart i hope you can help me with my problem.
I have a shopping cart which contains a session that i get when selecting values on database.
I have also a textbox which contains a desired budget.

My problem is I want to have a error message which can detect if the total price of the session is greater than the budget.

here is my code I hope you can help me
<form method="get">



Budget:
<input type="text" name="budget" class="txtfield" placeholder="Please enter your desired budget">


Service Type:

<select name="servicetype" class="txtfield">
<option>Wedding</option>
<option>Debut</option>
<option>Birthday</option>
</select>




<input type="submit" name="search" value="Search" class="btn btn-warning">


</form>

Desired Amount:


Please enter your desired amount';
}
else
{
$servicetype = $_GET['servicetype'];
$results = $mysqli->query("SELECT service_inclusion,price,servicetype,soid FROM service_offer
where servicetype='$servicetype' ORDER BY soid ASC");
if ($results)
{

while($obj = $results->fetch_object())
{

echo '';
echo '<form method="get" action="cart_update.php">';

echo ''.$obj->service_inclusion.'';
echo 'Price: '.$currency.$obj->price.' ';
echo 'Service Type: '.$obj->servicetype.' ';
echo '';
echo '<button style="background:#F01818; color:white;border:0;">Add Services</button>';
echo '';
echo '<input type="hidden" name="service_inclusion" value="'.$obj->service_inclusion.'" />';
echo '<input type="hidden" name="type" value="add" />';
echo '<input type="hidden" name="soid" value="'.$obj->soid.'" />';
echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
echo '</form>';
echo '';
}
}
}

?>

Your Shopping Cart
';
if($_GET['budget'] > $cart_itm['price'])
{
$message = 'error';
}
else
{
foreach ($_SESSION["products"] as $cart_itm)
{

echo '';
echo '×';
echo ''.$cart_itm["name"].'';
echo 'Price :'.$currency.$cart_itm["price"].'';
echo '';
$subtotal = ($cart_itm["price"]);
$Total = ($total + $subtotal);

}echo'';
echo 'Total : '.$currency.$Total.' Check-out!';
echo 'Empty Cart';
} }
else
{
echo 'Your Cart is empty';

}}
?>;
<script type="text/javascript">
</script>
Posted
Updated 12-Feb-15 20:47pm
v2

1 solution

 
Share this answer
 
Comments
Patrick sarmiento 16-Feb-15 3:25am    
sorry sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900