That isn’t a column name - you can either reference it by its position in the results or amend the query to assign a column name to that column, for example
But its working that giving me the mean value , The problem is happening to the sql quary in if condition ,
upto if condition its showing out put when i echo $ $meanduration;
So what actually happens that should not, or does not happen that should? Do you get any error messages? What happens if $meanduration actually is 119 or 120, as it won’t run either query then? Do you actually have rows where the id field contains the string “field_name”? I am confused that it’s retrieving data, in fairness, or have you edited that information to not show confidential data?
in database table field value is not updating values, its remain same , not showing any error massege ,
if($meanduration > 120){
mysql_query(“UPDATE table_name SET column_name = ‘3’ WHERE column_name=‘value’”);
}
elseif($meanduration < 119)
{
mysql_query(“UPDATE table_name SET column_name =‘0’ WHERE coulmn_name
=‘value’”);
}
my problem is value is not updating in data base , $meanduration result is 55.33 , in data base sql is not executing
but if i give any string in the execution place of “if” and “else” condition insted of sql query its giving me right ans , why sql query is not execute and not replacing the value while i reload the page
There are two PHP extensions (libraries with set of functions) to work with MySQL - mysql (old and deprecated one) and mysqli (improved). Both of these extensions have a similar functions (like mysql_query and mysqli_query), but mysqli also allows using object-oriented style ($conn->query()).
In your code you’re using mysqli extension to set a database connection:
$conn = new mysqli($servername, $username, $password, $dbname);
^
so you have to use mysqli functions in the rest of code too, either mysqli_query or $conn->query