There is a script which pings all the ip addresses in the column "ip_address", I need to ping after reports he wrote in the column "status". I.e. If the computer is online, in the column "status" write the value 1, if the offline database set to 0. Example:
He does not want to write this value. Here's my script:
<?php
include('db.php');
foreach($test as $value){
exec("ping -c 4 " . $value->ip_address, $output, $result);
if ($result == 0) {
$insert_sql = "INSERT INTO test ('status')VALUES('1');";
}else{
$insert_sql = "INSERT INTO test ('status')VALUES('0');";
}
echo "<br/>" . $insert_sql;
}
?>
This is what happens :
UPD:
<?php
include('db.php');
foreach($test as $value){
exec("ping -c 4 " . $value->ip_address, $output, $result);
if ($result == 0) {
$insert_sql = "update test set status='1' where ip_addres = '".$value->ip_address."'";
mysqli_query($insert_sql);
}else{
$insert_sql = "update test set status='0' where ip_addres = '".$value->ip_address."'";
mysqli_query($insert_sql);
}
}
?>
That's right?