Click here to Skip to main content
15,890,123 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionRe: How to Delete file when Selected from Dropdown List Pin
Richard MacCutchan10-Mar-15 22:08
mveRichard MacCutchan10-Mar-15 22:08 
AnswerRe: How to Delete file when Selected from Dropdown List Pin
Member 1150850510-Mar-15 22:11
Member 1150850510-Mar-15 22:11 
GeneralRe: How to Delete file when Selected from Dropdown List Pin
Richard MacCutchan10-Mar-15 23:10
mveRichard MacCutchan10-Mar-15 23:10 
QuestionDisplay results based on dropdown selected dropdown value Pin
samflex10-Mar-15 7:47
samflex10-Mar-15 7:47 
AnswerRe: Display results based on dropdown selected dropdown value Pin
tobisoft28-Apr-15 13:34
tobisoft28-Apr-15 13:34 
GeneralRe: Display results based on dropdown selected dropdown value Pin
nilprajapati8-Dec-15 22:13
nilprajapati8-Dec-15 22:13 
QuestionCan't get ubuntu boot to recognize USB drive! Pin
swampwiz22-Feb-15 7:46
swampwiz22-Feb-15 7:46 
QuestionHow Can I Detect Whether My Total Price Is Greater Than The Price I Inputted On Textbox Pin
Patrick sarmiento12-Feb-15 20:49
Patrick sarmiento12-Feb-15 20:49 
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
HTML
 <form method="get">

<table>
          <tr>
            <td style="padding:5px;">Budget:</td>
            <td style="padding:5px;"><input type="text" name="budget" class="txtfield" placeholder="Please enter your desired budget"></td>
          </tr>
          <tr>
            <td style="padding:5px;">Service Type:</td>
          <td style="padding:5px;">
              <select name="servicetype" class="txtfield">
                <option>Wedding</option>
                <option>Debut</option>
                <option>Birthday</option>
              </select>
            </td>
          </tr>
          <tr>
            <td style="padding:5px;"></td>
            <td style="padding:5px;"><input type="submit" name="search" value="Search" class="btn btn-warning"></td>
          </tr>
        </table>
        </form>
    <?php if(isset($_GET['search'])):?>
        <h3 style="background:red; color:white; width:300px; padding:5px;">Desired Amount: <?php echo $_GET['budget'] ?></h3>
    <?php endif?>
    <div class="products">
    <?php
    //current URL of the Page. cart_update.php redirects back to this URL
	$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    if(isset($_GET['search']))
    {

$servicetype = $_GET['servicetype'];
    if($_GET['budget'] =="")
    {
        echo'<div class="alert alert-warning">Please enter your desired amount</div>';
    }
    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 '<div class="product">'; 
            echo '<form method="get" action="cart_update.php">';
			
  echo '<div class="product-content"><h3>'.$obj->service_inclusion.'</h3>';
            echo '<div class="product-desc">Price: '.$currency.$obj->price.' </div>';
            echo '<div class="product-desc">Service Type: '.$obj->servicetype.' </div>';
            echo '<div class="product-info">';
			echo '<button style="background:#F01818; color:white;border:0;">Add Services</button>';
			echo '</div></div>';
            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 '</div>';
        }
      }
    }

 ?>
    
 </div>
    
<div class="shopping-cart">
<h2>Your Shopping Cart</h2>
<?php
if(isset($_SESSION["products"]))
{
    $total = 0;
    echo '<ol>';
    if($_GET['budget'] > $cart_itm['price'])
    {
        $message = 'error';
    }
    else
    {
    foreach ($_SESSION["products"] as $cart_itm)
    {

  echo '<li class="cart-itm">';
        echo '<span class="remove-itm"><a href="cart_update.php?removep='.$cart_itm["code"].'&return_url='.$current_url.'">×</a></span>';
        echo '<h3>'.$cart_itm["name"].'</h3>';
        echo '<div class="p-price">Price :'.$currency.$cart_itm["price"].'</div>';
        echo '</li>';
        $subtotal = ($cart_itm["price"]);
        $Total = ($total + $subtotal);
        
   }echo'</ol>';
    echo '<span class="check-out-txt"><strong>Total : '.$currency.$Total.'</strong> <a href="view_cart.php">Check-out!</a></span>';
	echo '<span class="empty-cart"><a href="cart_update.php?emptycart=1&return_url='.$current_url.'">Empty Cart</a></span>';
}   }
else
{
    echo 'Your Cart is empty';

}}
?>

</div>
<div style="clear:both;"></div>    
</div>
<script type="text/javascript">
    <?php 
        if(isset($message))
        {
            echo "alert('$message')";
        }
    ?>
</script>


modified 13-Feb-15 4:49am.

SuggestionRe: How Can I Detect Whether My Total Price Is Greater Than The Price I Inputted On Textbox Pin
Richard MacCutchan12-Feb-15 22:50
mveRichard MacCutchan12-Feb-15 22:50 
QuestionPass datepicker value to PHP & MySQL Pin
Jassim Rahma7-Feb-15 23:28
Jassim Rahma7-Feb-15 23:28 
AnswerRe: Pass datepicker value to PHP & MySQL Pin
Thomas Daniels8-Feb-15 2:59
mentorThomas Daniels8-Feb-15 2:59 
QuestionMake this Hashing in PHP Pin
Jassim Rahma28-Jan-15 21:05
Jassim Rahma28-Jan-15 21:05 
AnswerRe: Make this Hashing in PHP Pin
Richard MacCutchan28-Jan-15 21:24
mveRichard MacCutchan28-Jan-15 21:24 
Question$_COOKIE[session_name()] vs session_id() which one holds good? Pin
Jayapal Chandran28-Jan-15 10:11
Jayapal Chandran28-Jan-15 10:11 
QuestionApache2.sin do not peer *.pl domain Pin
pixcraft14-Jan-15 2:33
pixcraft14-Jan-15 2:33 
QuestionFlash drive on Linux Pin
ForNow13-Dec-14 14:28
ForNow13-Dec-14 14:28 
AnswerRe: Flash drive on Linux Pin
Michael Martin9-Jan-15 20:22
professionalMichael Martin9-Jan-15 20:22 
Questionselectbox sql problems Pin
ceewhitehead7-Nov-14 0:39
ceewhitehead7-Nov-14 0:39 
AnswerRe: selectbox sql problems Pin
Richard MacCutchan7-Nov-14 0:59
mveRichard MacCutchan7-Nov-14 0:59 
GeneralRe: selectbox sql problems Pin
ceewhitehead7-Nov-14 2:29
ceewhitehead7-Nov-14 2:29 
GeneralRe: selectbox sql problems Pin
Richard MacCutchan7-Nov-14 2:40
mveRichard MacCutchan7-Nov-14 2:40 
Questionzend & php code Pin
vaguemind2-Nov-14 21:02
vaguemind2-Nov-14 21:02 
Questionlaunch a web app using python Pin
Member 94937201-Nov-14 22:02
Member 94937201-Nov-14 22:02 
AnswerRe: launch a web app using python Pin
Richard MacCutchan1-Nov-14 22:09
mveRichard MacCutchan1-Nov-14 22:09 
QuestionCode Samples Pin
Brandi Boseman29-Oct-14 8:00
Brandi Boseman29-Oct-14 8:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.