PHP - Rupees Slider control - Asked By sachin on 13-Nov-14 06:49 AM

Hi guys
i have use the folowing for slider control


 $min = $values[0];
   $max = $values[1];

<script type="text/javascript">
$(function() {
    $( "#slider-range" ).slider({
    range: true,
    min: 1000,
    max: 90000,
    values: [ <?php echo $min; ?>, <?php echo $max; ?> ],
    slide: function( event, ui ) {
      $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
    }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
    " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  });
</script>

Its working fine
But i tried replacing the $ with RS. I get NAN and error
Robbe Morris replied to sachin on 13-Nov-14 08:06 AM
The amount.val is just setting the value for display.  I think you are going to have to dig into the Slider code and see where it pulls its values from and converts them to numbers for math functions.  I wouldn't be surprised to see a parsing of the string and removal of a dollar sign.  You may need to include code there that gets rid of your rupee symbol.
sachin replied to Robbe Morris on 17-Nov-14 10:14 AM
yes i tried replacing $ with RS
It displays while page load
but on changing the slider values
it executes the else part

if($_POST)
{
    mysqli_real_escape_string($connection,$_POST['amount']);
    $values = str_replace(' ','',$_POST['amount']);
    $values = str_replace('$','',$values);
    $values = explode('-',$values);
    $min = $values[0];
    $max = $values[1];
    $res = mysqli_query($connection,'select `id`,`product_name`, `details`,`price` from products where `price` BETWEEN "'.$min.'" AND "'.$max.'"');
    $count  =   mysqli_num_rows($res);


    $dynamicList = "";
    //$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
    //$productCount = mysql_num_rows($sql); // count the output amount
    if ($count > 0)
    {
        while($row = mysqli_fetch_array($res))
        {
       $id = $row["id"];
             $product_name = $row["product_name"];
             $price = $row["price"];
             //$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
            
             $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
                          <tr>
                              <td width="17%" valign="top">
                                <a href="product.php?id=' . $id . '">
                                    <img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77"                                height="102" border="1" /></a></td>
                          <td width="83%" valign="top">' . $product_name . '<br /> RS. ' . $price . '<br />
                          <a href="product.php?id=' . $id . '">View Product Details</a></td>
                        </tr>
                        </table>';
        }
    }
     else
      {
        $dynamicList = "<b><i>We have Currently no products in this range. Sorry Check again later ! </i></b>";
        
      }
}


this is wat i ve used
Robbe Morris replied to sachin on 17-Nov-14 10:32 AM
This line is the issue:

 $values = str_replace('$','',$values);

 add this below it to take care of rupees as well as dollars. 

 $values = str_replace('RS','',$values);
sachin replied to Robbe Morris on 20-Nov-14 12:22 PM
Thanks a ton bro... :)
 
One more query :

I have used a third party website from paypal for storing the product session, but in paypal standard they use $ .
How to change rupees over there.
here is the code


<?php
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//     Section 5  (render the cart for the user to view on the page)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$cartOutput = "";
$cartTotal = "";
$pp_checkout_btn = '';
$product_id_array = '';
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1 || (isset($_POST['btn1']))) {
    $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>";
} else {
    // Start PayPal Checkout Button
    $pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="upload" value="1">
    <input type="hidden" name="business" value="sachin30190@gmail.com">';
    // Start the For Each loop
    $i = 0;
    foreach ($_SESSION["cart_array"] as $each_item) {
        $item_id = $each_item['item_id'];
        $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while ($row = mysql_fetch_array($sql)) {
            $product_name = $row["product_name"];
            $price = $row["price"];
            $details = $row["details"];
        }
        $pricetotal = $price * $each_item['quantity'];
        $cartTotal = $pricetotal + $cartTotal;
        setlocale(LC_MONETARY, "en_IN");
      $pricetotal = number_format($pricetotal,2);
        // Dynamic Checkout Btn Assembly
        $x = $i + 1;
        $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">
      <input type="hidden" name="amount_' . $x . '" value="' . $price . '">
      <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '">  ';
        // Create the product array variable
        $product_id_array .= "$item_id-".$each_item['quantity'].",";
        // Dynamic table row assembly
        $cartOutput .= "<tr>";
        $cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
        $cartOutput .= '<td>' . $details . '</td>';
        $cartOutput .= '<td>RS.' . $price . '</td>';
        $cartOutput .= '<td><form action="cart.php" method="post">
        <input name="quantity" type="hidden" value="' . $each_item['quantity'] . '" size="1" maxlength="2" />
        <input name="item_to_adjust" type="hidden" value="' . $item_id . '" />
        </form>';
        $cartOutput .=  $each_item['quantity'] . '</td>';
        $cartOutput .= '<td>' . $pricetotal . '</td>';
        $cartOutput .= '</tr>';
        $i++;
    }
    setlocale(LC_MONETARY, "en_IN");
    $cartTotal =number_format($cartTotal,2);
    $cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." INR</div>";
    
    // Finish the Paypal Checkout Btn
    $pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '">
    <input type="hidden" name="notify_url" value="storescripts/my_ipn.php">
    <input type="hidden" name="return" value="checkout_complete.php">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="cbt" value="Return to The Store">
    <input type="hidden" name="cancel_return" value="paypal_cancel.php">
    
    <input type="hidden" name="currency_code" value="INR">
    <input type="hidden" name="notify_url" value="http://nabsac2014.net46.net/index.php">
    <input type="hidden" name="return" value="http://nabsac2014.net46.net/index.php">
    <input type="hidden" name="cancel_return" value="http://nabsac2014.net46.net/index.php">
    <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - its fast, free and secure!" style="float:right;">
    </form>';
}
?>