Jump to content

[SOLVED] Why does it loop and not output the data?


jamcoupe

Recommended Posts

Hey I have been able to make a code to fetch data from a database however after adding stylesheets and using divs and classes it does go through the rows but it wont pull the information.

 

I have 3 records in the database and I get this:

picture3vig.png

 

 

Here is what I have coded:

<?php
  $query = "SELECT *
		FROM news
		ORDER BY id DESC";

  $get_news = mysql_query($query, $connect);
query_check($get_news);
	while ($news = mysql_fetch_array($get_news)) { ?>

          <div class="news">
              <h3 class="news_title"><a href="news.php?article="<?php $news['id']; ?>"> <?php $news['title'] ?></a></h3>
                  <p class="news_content"><?php $news['content']; ?></p>
                  <p class="news_bottom">Posted by [username] on [<?php $news['date'];?>]</p>
          </div>
          <br /><br />

<?php }
?>

Hey I have been able to make a code to fetch data from a database however after adding stylesheets and using divs and classes it does go through the rows but it wont pull the information.

 

I have 3 records in the database and I get this:

picture3vig.png

 

 

Here is what I have coded:

<?php
  $query = "SELECT *
		FROM news
		ORDER BY id DESC";

  $get_news = mysql_query($query, $connect);
query_check($get_news);
	while ($news = mysql_fetch_array($get_news)) { ?>

          <div class="news">
              <h3 class="news_title"><a href="news.php?article="<?php $news['id']; ?>"> <?php $news['title'] ?></a></h3>
                  <p class="news_content"><?php $news['content']; ?></p>
                  <p class="news_bottom">Posted by [username] on [<?php $news['date'];?>]</p>
          </div>
          <br /><br />

<?php }
?>

You missed echo in <?php $news['id']; ?> and in others

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.