i will be very thankful if you could help in the following code
the error
Code: Select all
<?php
$thehost = 'localhost';
$dbname = 'tutorial';
$username = 'root';
$userpass = '';
$dbh = new PDO ("mysql:host = $thehost ; dbname = $dbname", $username, $userpass)
or die ("Error");
foreach($dbh->query('SELECT SUM(option1+option2) FROM feedback') as $row)
{
echo "<tr>";
echo "<td>" . $row['SUM(option1+option2)'] . "</td>";
echo "</tr>";
}
?>
Basically i want to add the values of two columns and print them
but the error i am facing is
Warning: Invalid argument supplied for foreach()
and neither its adding up
thanks alot in advance