News Headlines Help

Status
Not open for further replies.

Mega

Posting Freak
Mar 23, 2013
858
155
Dear devbest,
I need help. I'm using Habsys 2's system. All okay just I want it to be like. Anyone help?
sumh45qu


But when i integrate these codes
PHP:
<!-- News Headlines -->
<div class="newscont">
<div id="newscont">
<div class="news_text">
 
<?php
$latest10 = mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 10");
if(mysql_num_rows($latest10) == 0){
    echo 'There are no news topics!';
}else{
    while($l10 = mysql_fetch_array($latest10)){
        $id = $l10["id"];
        $title = $l10["title"];
        $comments = $l10["comments"];
        $author = $l10["author"];
        $username = userRow($author, 'username');
        echo '<a href="article.php?id='.$id.'" title="Author: '.$username.'  |  Comments: '.$comments.'">'.$title.'</a><br>';
    }
}
?>
 
</div>
<div id="post_date"></div>
</div>
</div>

It become like this:
7rx3jr5d


Thank you
 

Sean

‫‫‫‫‫‫  ‫  Don't Worry, Be Happy
Dec 12, 2011
1,121
405
You need to have the styling:

<div class="newscont">
<div id="newscont">
<div class="news_text">

Inside the While loop

so that it echos one news box for each title.
 

Sean

‫‫‫‫‫‫  ‫  Don't Worry, Be Happy
Dec 12, 2011
1,121
405
Try this:

PHP:
<!-- News Headlines -->
 
<?php
$latest10 = mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 10");
if(mysql_num_rows($latest10) == 0){
    echo 'There are no news topics!';
}else{
    while($l10 = mysql_fetch_array($latest10)){
        $id = $l10["id"];
        $title = $l10["title"];
        $comments = $l10["comments"];
        $author = $l10["author"];
        $username = userRow($author, 'username');
        echo '<div class="newscont">
              <div id="newscont">
              <div class="news_text">';
        echo '<a href="article.php?id='.$id.'" title="Author: '.$username.'  |  Comments: '.$comments.'">'.$title.'</a><br>';
        echo '</div>
              <div id="post_date"></div>
              </div>
              </div>';
    }
}
?>
 

Mega

Posting Freak
Mar 23, 2013
858
155
Try this:

PHP:
<!-- News Headlines -->
 
<?php
$latest10 = mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 10");
if(mysql_num_rows($latest10) == 0){
    echo 'There are no news topics!';
}else{
    while($l10 = mysql_fetch_array($latest10)){
        $id = $l10["id"];
        $title = $l10["title"];
        $comments = $l10["comments"];
        $author = $l10["author"];
        $username = userRow($author, 'username');
        echo '<div class="newscont">
              <div id="newscont">
              <div class="news_text">';
        echo '<a href="article.php?id='.$id.'" title="Author: '.$username.'  |  Comments: '.$comments.'">'.$title.'</a><br>';
        echo '</div>
              <div id="post_date"></div>
              </div>
              </div>';
    }
}
?>

Thanks, it worked. But how can I maximum it only 3 headlines?
 

Sean

‫‫‫‫‫‫  ‫  Don't Worry, Be Happy
Dec 12, 2011
1,121
405
use this code:

PHP:
<!-- News Headlines -->
 
<?php
$latest3 = mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 3");
if(mysql_num_rows($latest3) == 0){
    echo 'There are no news topics!';
}else{
    while($l3 = mysql_fetch_array($latest3)){
        $id = $l3["id"];
        $title = $l3["title"];
        $comments = $l3["comments"];
        $author = $l3["author"];
        $username = userRow($author, 'username');
        echo '<div class="newscont">
              <div id="newscont">
              <div class="news_text">';
        echo '<a href="article.php?id='.$id.'" title="Author: '.$username.'  |  Comments: '.$comments.'">'.$title.'</a><br>';
        echo '</div>
              <div id="post_date"></div>
              </div>
              </div>';
    }
}
?>
 

Mega

Posting Freak
Mar 23, 2013
858
155
use this code:

PHP:
<!-- News Headlines -->
 
<?php
$latest3 = mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 3");
if(mysql_num_rows($latest3) == 0){
    echo 'There are no news topics!';
}else{
    while($l3 = mysql_fetch_array($latest3)){
        $id = $l3["id"];
        $title = $l3["title"];
        $comments = $l3["comments"];
        $author = $l3["author"];
        $username = userRow($author, 'username');
        echo '<div class="newscont">
              <div id="newscont">
              <div class="news_text">';
        echo '<a href="article.php?id='.$id.'" title="Author: '.$username.'  |  Comments: '.$comments.'">'.$title.'</a><br>';
        echo '</div>
              <div id="post_date"></div>
              </div>
              </div>';
    }
}
?>

Thanks :) Mod close thread please
 
Status
Not open for further replies.

Users who are viewing this thread

Top