Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.