1

Good day, I have a huge problem, I know PHP uses mysql database and javascript do not. But the thing I'm trying to accomplish is to use a database number value "like 9000" and subtract it from a javascript number value that is being generated by clicking on prducts "like 3000" then it must give a final answer of 6000.

Here's what I have

<table><tbody>
<tr>
<td class='odd'><?php echo htmlentities($_SESSION['usr']['usr'], ENT_QUOTES, 'UTF-8');   
?></td>
<td class='even'>&nbsp;</td>
</tr>
<tr>
<td class='odd'>Your Value Points: </td>
<td class='even'><span id="valuep" class="valuep"><?php echo     
htmlentities($_SESSION['usr']['points'], ENT_QUOTES, 'UTF-8'); ?></span></td>
</tr>
<tr>
<td class='odd'>&nbsp;</td>
<td class='even'>&nbsp;</td>
</tr>
<tr><td class='odd'>Total Items: </td><td class='even'><span id='simpleCart_quantity'   
class='simpleCart_quantity'></span></td></tr>
<tr><td class='odd'>SubTotal: </td><td class='even'><span id='simpleCart_total' 
class='simpleCart_total'></span></td></tr>

<tr><td class='odd'>&nbsp;</td><td class='even'>&nbsp;</td></tr>
<tr><td class='odd'>Total</td><td class='even'>

<?php
$first_number = htmlentities($_SESSION['usr']['points'], ENT_QUOTES, 'UTF-8'); 
$second_number = "This must be the simpleCart_total";
$sum_total = $first_number - $second_number;
print ($sum_total);
?>

</td>
</tr>

</tbody>
</table>
Christoff
  • 21
  • 7

1 Answers1

0

1 - Hidden input

You could create a hidden input. In your JS script where you define the number, you add it to the hidden input. You POST the page and use the value

2 - Cookie

Set the value in a Cookie with JS, and retrieve it with PHP.

GreyRoofPigeon
  • 17,833
  • 4
  • 36
  • 59
  • Hi @LinkinTED thanks for your comment, can you please give example code on how this will be done, because i'm not a javascript expert. – Christoff Sep 30 '13 at 11:16
  • Well, I won't code for you, but I can give you these helpful links: 1) https://www.google.nl/search?q=javascript+set+value+in+input 2) https://www.google.nl/search?q=javascript+set+cookie – GreyRoofPigeon Sep 30 '13 at 11:18
  • Thanks again for your quick reply. If you have time, can you please go have a look at this: http://hiteksecurity.net/Demo3/valueshop/index.php - Username = demo - Password = f2130c then maybe you will get the idea i'm looking at doing – Christoff Sep 30 '13 at 11:52