I am defining the subtraction variable like so:
$query = "
SELECT * FROM around WHERE `long` != '' ORDER BY id DESC";
$result = mysql_query( $query );
$select_maxlong = mysql_query("SELECT long FROM around WHERE
`id`='$max_id'");
$row3 = mysql_fetch_row($select_maxlong);
$max_long = $row3[0];
Then I need to subtract $max_long from the array value below:
while ( $row = mysql_fetch_assoc( $result ) ) {
echo $row['long'];}
I have tried:
foreach($row as $row) {
$car = $max_long;
echo "u";
echo $car - $row['long'] ; }
But the output is not correct.
If there are 10 numbers in an array, $row['long'], I want to subtract $max_long from each of them, and echo the result.
foreach($row as $row)Whoa!$rowis an array and you're doingforeach, then on first iteration$rowwill become a first item of$row. And what's next?mysql_*functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.