Jump to content

[SOLVED] displaying data from mysql


MoFish

Recommended Posts

hello everyone. i'm trying to display the contents of a database in a separate table for each, however am running into a bit of trouble. it currently displays the first row of data fine in its table but doesn't display the second. here is the error i get.

[color=red]Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in D:\web-server\www\Abertay\displaynews.php on line 29[/color]

[code]
$query_SelectNews = "SELECT * FROM newstable ORDER BY news_id ASC";
$SelectNews = mysql_query($query_SelectNews, $ConnectAbertay) or die(mysql_error());
$row_SelectNews = mysql_fetch_assoc($SelectNews);
$totalRows_SelectNews = mysql_num_rows($SelectNews);
?>

<title>DisplayNews</title>

<?php
mysql_free_result($SelectNews);
?>
<?php do { ?>
<table width="400px" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <td><?php echo $row_SelectNews['news_title']; ?></td>
    <td><?php echo $row_SelectNews['news_date']; ?></td>
  </tr>
  <tr>
    <td><?php echo $row_SelectNews['news_image']; ?></td>
    <td><?php echo $row_SelectNews['news_message']; ?></td>
  </tr>
  <tr>
    <td colspan="2"><?php echo $row_SelectNews['news_postedby']; ?></td>
  </tr>
</table>
<?php } while ($row_SelectNews = mysql_fetch_assoc($SelectNews)); ?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31038-solved-displaying-data-from-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.