How to store PHP/SQL input value to daemon using JSONRPC?

How to store PHP/SQL input value to daemon using JSONRPC?
0

#1

I am working on web application, i am stuck at point i have to make logic where when user put value in input, submit button input value store in daemon. working on PHP/SQL language. how to do?


#2

There is no need to use jQuery unless you have some specific need to. It’s simple enough to use just HTML form.
Form should submit data to php page. Name attribute is used to identify value from each text field For example :slight_smile:

  <form method="POST" action="process_data.php">
     <input type="text" name="field1">
     <input type="submit" value="Send">
  </form>

Then on page called process_data.php you should retrieve values from form and execute SQL statements against mySQL database :slight_smile:

<?php
            $field = $_POST["field1"];

            $query = "INSERT INTO table_name VALUES($field);

       .... mysql connecton making and executing query commands
?>

#3

Thanks. i appreciate. :slight_smile:

After storing value in database, how can i add this in current balance? what’s the code for storing input value in current balance?


#4

Well, you can define a global variable for this

<?php $GLOBALS['sum'] = $GLOBALS['sum'] + $_POST['field1']; On the other hand, global variables can be not what you want. You can always fire up SQL command to get sum of what is stored in database $query = "SELECT SUM('field1') FROM table_name"; This way you will stay off global variables but one SQL query can be costly because for each form submit you will execute one SQL query more. Choose what you like :)

#5

Hey, It’s working perfectly fine. You are great. Thanks. :grinning:
how current balance can update from database? balance always increases or decreases how can i do this?


#6
<?php
            $field1 = $_POST['field1'];
            $querySum = "SELECT SUM(field1) FROM table_name";
            .... execute query and get sum into $sum variable
            $sum = $sum + $field1;
            $queryUpdate = "INSERT INTO table_name VALUES($sum)";