Update a field multiplying another field and a constant in sql with php [closed]
I have to do this: UPDATE mytable SET value1 = (value2 * X) Where value1 and value2 are fields of that table, and X is a constant, defined by the user. How can I make it work?
Here's how to do it using PDO syntax for prepared statements. $stmt = $pdo->prepare("UPDATE mytable SET value1 = value2 * :x"); $stmt->bindParam(':x', $variable_from_user); $stmt->execute(); Mysqli syntax is similar. $stmt = $mysqli->prepare("UPDATE mytable SET value1 = valu2 * ?"); Stmt->bind_param("i", $variable_from_user); $stmt->execute();
Can a variable named as `$something` be referred to by `someting`, that is without the dollar sign?
Cannot login to php page when sql column type is changed from TEXT to varchar
Caesar Cipher not running as expected
User Profile Creation
PHP get time from personal identity number under 1970
Use Product Image as category Image in Virtuemart
Swiftmailer: Missing space in subject email
Implode multidimensional array with different glue in php
Generating a random number not working on live server
How do I use or operator in PHP?
Continuously skip an element in foreach loop
Using interfaces in PHP
Creating a “Numbers Grid” with for() *logic thing*
php - AND with two condition
Allowed memory size greater than required but throwing fatal error
Displaying XML dynamically using PHP and URL variables