Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

news.php

Asked Modified Viewed 3,574 times
A
abdifatahnuur
A
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

how to make news panels like this.
soomaaliweyn.net/images/tijaabo.png
0 replies

9 posts

C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

I got some time to kill while uploading my stuff.

create a new panel. copy and paste the following code and save.


$news_category_id = "1"; // type your category id here.
$result = dbquery("SELECT * FROM ".DB_NEWS." WHERE news_cat='$news_category_id' ORDER BY news_id ASC, LIMIT 0,15");
if (dbrows($result)>0) {
open_table("News Category");
echo "<ul>";
while ($data = dbarray($result)) {
$news_id = $data['news_id'];
$news_title = $data['news_subject'];
echo "<li><a href='".FUSION_SELF."&amp;readmore=$news_id'> $news_title</a></li>
}
echo "</ul>";
} else { echo "There are no news in this category"; }
closetable();


If there is any error, show me. I am coding here. Not sure if the results are right.
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

I don't believe that is entirely what he wants hien...

Try putting this into a panel:
$news_cat_ids = "1, 2"; //separate each category with a comma and a space
$news_cat_ids = explode(", ", $news_cat_ids);
$i = 0;
if(!empty($news_cat_ids)){
   foreach($news_cat_ids as $news_cat_box){
      $result = dbquery("SELECT news_cat_name FROM ".DB_NEWS_CATS." WHERE news_cat_id='".intval($news_cat_box)."' LIMIT 0, 1");
      if(dbrows($result)){
         $data = dbarray($result);
         $result = dbquery("SELECT * FROM ".DB_NEWS." WHERE news_cat='".intval($news_cat_box)."' ORDER BY news_id ASC LIMIT 0, 10");
         echo "<div style='width:49%;position:relative;padding:1px;magin:1px;float:".(($i % 2 == 0) ? "left" : "right").";overflow:hidden;'>\n";
         opentable($data['news_cat_name']);
         if(dbrows($result)){
            echo "<ul>";
            while($data = dbarray($result)){
               echo "<li><a href='".BASEDIR."news.php?readmore=".$data['news_id']."'>".$data['news_subject']."</a></li>\n";
            }
            echo "</ul>";
         }else{
            echo "<p>No news for this category.</p>\n";
         }
         closetable();
         echo "</div>\n";
      }
   $i++;
   }
   echo "<div style='clear:both;'></div>\n";
}
0 replies
D
Daronna
D
  • Junior Member, joined since
  • Contributed 10 posts on the community forums.
  • Started 2 threads in the forums
answered
Junior Member

Hi Hien;

I tried the above code and this is the error I got:
Parse error: syntax error, unexpected '/'
\panels.php(74) : eval()'d code on line 12

Thank you in advance
Daronna
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

Read my post that is just before yours.... I think that is what the topic starter wanted originally.
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Well Tyler :G
0 replies
D
Daronna
D
  • Junior Member, joined since
  • Contributed 10 posts on the community forums.
  • Started 2 threads in the forums
answered
Junior Member

Thank you Tyler, works good for me, but... is it possible to have the category name 'linked' to that particular category?

And sorry for butting in on someone else's topic ;)

Thank you
Daronna
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

Yeah, rather than the "heading" linking to the category I added a "View All Entries" under the list of news entries... it's what I had to resort too

$news_cat_ids = "1, 2";
$news_cat_ids = explode(", ", $news_cat_ids);
$i = 0;
if(!empty($news_cat_ids)){
   foreach($news_cat_ids as $news_cat_box){
      $result = dbquery("SELECT news_cat_name FROM ".DB_NEWS_CATS." WHERE news_cat_id='".intval($news_cat_box)."' LIMIT 0, 1");
      if(dbrows($result)){
         $data = dbarray($result);
         $result = dbquery("SELECT * FROM ".DB_NEWS." WHERE news_cat='".intval($news_cat_box)."' ORDER BY news_id ASC LIMIT 0, 10");
         echo "<div style='width:49%;position:relative;padding:1px;magin:1px;float:".(($i % 2 == 0) ? "left" : "right").";overflow:hidden;'>\n";
         opentable($data['news_cat_name']);
         if(dbrows($result)){
            echo "<ul>";
            while($data = dbarray($result)){
               echo "<li><a href='".BASEDIR."news.php?readmore=".$data['news_id']."'>".$data['news_subject']."</a></li>\n";
            }
            echo "</ul>";
            echo "<p align='center'><a href='".BASEDIR."news_cats.php?cat_id=".$news_cat_box."'>View All Entries</a></p>\n";
         }else{
            echo "<p>No news for this category.</p>\n";
         }
         closetable();
         echo "</div>\n";
      }
   $i++;
   }
   echo "<div style='clear:both;'></div>\n";
}
0 replies
D
Daronna
D
  • Junior Member, joined since
  • Contributed 10 posts on the community forums.
  • Started 2 threads in the forums
answered
Junior Member

Works wonderfully, thank you

Daronna
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Solved solution but unsolved thread. Kinda wierd.. Lol
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 9 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
T
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
D
D
  • Junior Member, joined since
  • Contributed 10 posts on the community forums.
  • Started 2 threads in the forums
A
A
  • Newbie, joined since
  • Contributed 1 post on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet