News Article Issue

Gang67

|Jump out gang, we jump out those vehicles|
May 5, 2017
303
54
Hello, when I make a new news article it just adds on to each other and doesn't make it's own page.
zsngZNOGTVK-iMXA7Me2Tg.png


I would like it to create a page for each article instead of it adding them to the same page each time
Here is my php so far
PHP:
    <div id="news">
    <div id="news-top">
    <p class="top-titles">News</p>
    </div>
    <div class="inside-news" id="style-3">
        <?php


    $row1 = mysql_query("SELECT title,longstory,image,author FROM cmsnews");

    if (mysql_num_rows($row1) > 0)
    {
        while($row = mysql_fetch_assoc($row1)) {

?>
    <div id="pos-img">
   <img src='<?php  echo $row['image']; ?>' width="550" height="175" >
   </div><br>
   <div id="pos-news">
   <?php echo $row['longstory']; ?>
   </div>
            
<?php   }

    }  ?>
    </div>
    </div>
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
You are fetching all of articles and looping though them. You should be fetching 1 article, getting the assoc of it and just out printing. No loop. Based on the GET for your article ID
 

Gang67

|Jump out gang, we jump out those vehicles|
May 5, 2017
303
54
You are fetching all of articles and looping though them. You should be fetching 1 article, getting the assoc of it and just out printing. No loop. Based on the GET for your article ID
Is there any examples that you know about that I can look at to help me understand this?
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Example:

Link:
Code:
<?php
      $getNews = mysql_fetch_assoc(mysql_query("SELECT * FROM cms_news WHERE `id` = '".$_GET['id']."' LIMIT 1"));

echo $getNews['title']; //Will Outprint News Title
echo $getNews['caption'] //Will Outprint News Caption
?>

Will Show news for Article 2
 

Gang67

|Jump out gang, we jump out those vehicles|
May 5, 2017
303
54
Example:

Link:
Code:
<?php
      $getNews = mysql_fetch_assoc(mysql_query("SELECT * FROM cms_news WHERE `id` = '".$_GET['id']."' LIMIT 1"));

echo $getNews['title']; //Will Outprint News Title
echo $getNews['caption'] //Will Outprint News Caption
?>

Will Show news for Article 2
Got it working, thank you :)
 

Users who are viewing this thread

Top