0

whenever I am running this code

<?php

$db=mysql_connect('localhost','root','');
mysql_select_db('moviesite',$db);

$query= 'SELECT * FROM movie';
$result=mysql_query($query,$db) or die(mysql_error($db));
while ($row=mysql_fetch_assoc($result))
echo '<tr>';
 {
    foreach ($row as $value) {
        echo $value;

    }
}
?>

everything ok, properoutput...........

but after that I typed this code of the output in table

<?php

$db=mysql_connect('localhost','root','');
mysql_select_db('moviesite',$db);

$query= 'SELECT * FROM movie';
$result=mysql_query($query,$db) or die(mysql_error($db));
echo '<table border="1">';
while ($row=mysql_fetch_assoc($result))
echo '<tr>';
 {
    foreach ($row as $value) {

        echo '<td >' . $value . '</td>';


    }
    echo '<tr/>';
}
    echo '</table>';
?>

then browser is showing error like this.....

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\movie\fstpage.php on line 12

pls help me. I am a new programmer cant find the solution

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.