Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:17:18+00:00 2026-05-23T16:17:18+00:00

I have a PHP/MySQL News system which displayes the newest news article on the

  • 0

I have a PHP/MySQL News system which displayes the newest news article on the home page and a full list on a news page.

The newest article bit works but, my problem is that whenever i try to echo all the news article on the news page it either repeats the same or outputs one and nothing else.

**MySQL Information**

id INT AUTO_INCREMENT, 
author VARCHAR(xxx), 
title VARCHAR(xxx), 
message TEXT, 
date TEXT,
time TEXT,
PRIMARY KEY(id)

This is the insertion page (news_center.php)

<form action='/?module=admin&n=news_center_ac' method='post'>
<table align="center" width="68%">
    <tr>
          <td>Title</td>
          <td><input style="width:100%;" type='text' name='news_title' /></td>
    </tr>
    <tr>
          <td height="57">Message</td>
          <td><input style="width:100%; height:100%;" type='text' name='news_message' /></td>
    </tr>
    <tr>
          <td colspan='2'><input type='submit' /></td>
    </tr>
</table>

This is news_center_ac.php

<?php
$conn = mysql_connect(*Connection Information*) or die(mysql_error());
$db = mysql_select_db( "db372357229")or die(mysql_error());

$author == $_SESSION['name'];

if(!empty($_POST['news_title']) || !empty($_POST['news_message']))
{
    if(!empty($_POST['news_title']) && !empty($_POST['news_message']))
    {

            $date = date( 'jS F Y' );
            $time = date( 'H:i' );
            $query = "INSERT INTO news (id, author, title, content, date, time) VALUES('', '".$author."', '".$_POST['news_title']."', '".$_POST['news_message']."', '".$date."', '".$time."')" or die(mysql_error());
            $insert = mysql_query($query) or die(mysql_error());
            echo '<p>Successful News Update&nbsp;&nbsp;&ldquo;'.$_POST['news_title'].'&rdquo;';

    }
    else
    {
        echo '<p>Please fill in all fields</p>';
    }
}
?>

This is the Output on the news page (/news/index.php)

<?php
$conn = mysql_connect("*CONNECTION INFORMATION*") or die(mysql_error());
$db = mysql_select_db( "db372357229")or die(mysql_error());
$news = mysql_query("SELECT * FROM news ORDER BY date DESC,id DESC");
$output = mysql_fetch_array($news);
?>

*CONTENT*

<?php
foreach ($output as $value) {
echo "<p> &ldquo;" .$output['content']; 
echo "&rdquo;";
echo "Posted:" .$output['date'];
echo "&nbsp;" .$output['time']; 
}
?>

I just want it to output each news article in turn i can sort out the formatting later once it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:17:19+00:00Added an answer on May 23, 2026 at 4:17 pm

    You are misusing mysql_fetch_array(). It needs to be called in a loop, as it only returns one row at a time.

    $conn = mysql_connect("*CONNECTION INFORMATION*") or die(mysql_error());
    $db = mysql_select_db( "db372357229")or die(mysql_error());
    $news = mysql_query("SELECT * FROM news ORDER BY date DESC,id DESC");
    

    EDIT Added htmlentities() calls to convert html special characters

    while ($row = mysql_fetch_array($news)) {
      echo "<p> &ldquo;" . htmlentities($row['content']); 
      echo "&rdquo;";
      echo "Posted:" . htmlentities($row['date']);
      echo "&nbsp;" . htmlentities($row['time']);  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website under construction, using PHP MYSQL, which contains a news page
I currently have a news website setup in PHP/MYSQL that's a bit old and
I have created a php/mysql based chat page.It is like gmail chat.once i click
I have a news feed that has been developed using PHP, MySQL, and jQuery.
I want to make a simple news system using PHP and MySQL, right now
I made a simple news system with comments using PHP and MySQL, and it
I have an a href which looks like that: <a href=delete-news.php?deleteID=11>Delete</a> And file delete-news.php
So, in my website, I have a news system which has an option to
I have php mysql application and i want the phone numbers be saved in
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.