Forum Moderators: coopster
Here's my code:
<?
$dbh=mysql_connect ("localhost", "usr", "pw") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("mydb");
$sql = "SELECT title, link, description FROM reports order by title";
$result = mysql_query($sql);
for($r=1;$r<=mysql_num_rows($result);$r++){
$row = mysql_fetch_array($result);
echo'
<div class="books">
<div class="iframe">
<iframe src="$row[link]" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>
<h3>$row[title]</h3>
<p>$row[description]</p>
</div>
';} ;
?>
I get this when I open the page:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
Thanks!
To:
$num_rows = mysql_num_rows($result);
for($r=1;$r<=$num_rows;$r++){
This makes it so the 'mysql_num_rows' function isn't called each time the loop executes.
This should work ;)