Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.updatePhp = function(table, column, value, whereColumn, whereValue) {
- $http.post(
- "update-data.php", {
- 'table': table,
- 'column': column,
- 'value': value,
- 'whereColumn': whereColumn,
- 'whereValue': whereValue
- }
- );
- }
- $scope.updatePhp = function(table, column, value, whereColumn, whereValue) {
- console.log("Updating. Table: " + table + ", column: " + column + ", value: " + value + ", where: " + whereColumn + ", whereValue: " + whereValue);
- $http({
- method: 'POST',
- url: 'update-data.php',
- data: $.param({ table: table.toString(), column: column.toString(), value: value.toString(), whereColumn: whereColumn.toString(), whereValue: whereValue.toString() }),
- headers: { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' }
- }).then(function successCallback(response) {
- console.log("Success.");
- }, function errorCallback(response) {
- console.log("Error.");
- });
- }
- <?php
- //PHP posted info
- $info = json_decode(file_get_contents('php://input'), true);
- //Update the table
- $hostname_DB = "databaseHost";
- $database_DB = "databaseName";
- $username_DB = "databaseUser";
- $password_DB = "databasePass";
- $mysqli = mysqli_connect($hostname_DB, $username_DB, $password_DB, $database_DB, "port#" ) or die(mysqli_error());
- $table = $info->table;
- $column = $info->column;
- $value = $info->value;
- $whereColumn = $info->whereColumn;
- $whereValue = $info->whereValue;
- $query = "UPDATE '$table' SET '$column' = '$value' WHERE '$whereColumn' = '$whereValue' ";
- $mysqli->query($query) or die(mysqli_error());
- ?>
Add Comment
Please, Sign In to add comment