• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Featured article problem with db

Hokku

Member
Joined
Jul 25, 2013
Messages
95
Reaction score
17
Location
Extremadura, Spain
Edit:
Fixed it, will post the solution on sunday cuz im out.



Im trying to display a featured article on my website but i cant figure how to code and link it to the db, im using gesior and tfs 1.1, tried all the codes on the web and nothings semm to work on my server, its like the php is written differently.
what i wrote but nothing:
PHP:
$featured_article = $SQL->query("SELECT `z_featured_article`.`read_more` AS `read_more`, `z_featured_article`.`text` AS `text`, `z_featured_article`.`title` AS `title`, `z_featured_article`.`id` AS `id`, `z_featured_article`.`date` AS `date` FROM `z_featured_article` ORDER BY `date` DESC LIMIT 1;")->fetchAll();


I looked at this to write:
PHP:
$zapytanie = $SQL->query("SELECT `z_forum`.`post_topic`, `z_forum`.`author_guid`, `z_forum`.`post_date`, `z_forum`.`post_text`, `z_forum`.`id`, `z_forum`.`replies`, `players`.`name` FROM `z_forum`, `players` WHERE `section` = '1' AND `z_forum`.`id` = `first_post` AND `players`.`id` = `z_forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 6;")->fetchAll();

full code:
PHP:
//FEATURED ARTICLE
$featured_article = $SQL->query("SELECT `z_featured_article`.`read_more` AS `read_more`, `z_featured_article`.`text` AS `text`, `z_featured_article`.`title` AS `title`, `z_featured_article`.`id` AS `id`, `z_featured_article`.`date` AS `date` FROM `z_featured_article` ORDER BY `date` DESC LIMIT 1;")->fetchAll();
if(isset($featured_article[0]))
    {
        foreach($featured_article as $featured)
        {

            $news_content .= '
                <div id="FeaturedArticle" class="Box">
                    <div class="Corner-tl" style="background-image:url('.$layout_name.'/images/content/corner-tl.gif);"></div>
                    <div class="Corner-tr" style="background-image:url('.$layout_name.'/images/content/corner-tr.gif);"></div>
                    <div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div>
                    <div class="BorderTitleText" style="background-image:url('.$layout_name.'/images/content/title-background-green.gif);"></div>
                    <img id="ContentBoxHeadline" class="Title" src="'.$layout_name.'/images/header/headline-featuredarticle.gif" alt="Contentbox headline" />
                    <div class="Border_2">
                        <div class="Border_3">
                            <div class="BoxContent" style="background-image:url('.$layout_name.'/images/content/scroll.gif);">
                                <div id="TeaserThumbnail">';
                                if(!empty($featured['read_more'])){
                                    $news_content .= '
                                    <a href="'.$featured['read_more'].'">';
                                }
                                $news_content .= '
                                        <img src="'.$layout_name.'/images/news/announcement.jpg" width="150" height="100" border=0 alt="" />';
                                if(!empty($featured['read_more'])){
                                $news_content .= '
                                    </a>';
                                    }
                            $news_content .= '
                                </div>';
                                if(!empty($featured['read_more'])){
                                $news_content .= '
                                <a id="Link" href="'.$featured['read_more'].'">&raquo; read more</a>';
                                }
                                $news_content .= '
                                <div id="TeaserText">
                                    <div style="position: relative; top: -2px; margin-bottom: 2px;" >
                                        <b>'.$featured['title'].'</b>
                                    </div>
                                    '.$featured['text'].'
                                </div>      
                            </div>
                        </div>
                    </div>
                    <div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div>
                    <div class="CornerWrapper-b"><div class="Corner-bl" style="background-image:url('.$layout_name.'/images/content/corner-bl.gif);"></div></div>
                    <div class="CornerWrapper-b"><div class="Corner-br" style="background-image:url('.$layout_name.'/images/content/corner-br.gif);"></div></div>
                </div>
            ';
        }
    }
//FEATURED ARTICLE END

z_featured_article in db:
Untitled.png

If someone can tip me how can i link to the db would apreciate
 
Last edited:
I can't see anything wrong in your code - more, I even tested it and it works.

The code I used to test:
PHP:
$featured_article = $SQL->query("SELECT `title`, `body` FROM `myaac_news` ORDER BY `date` DESC LIMIT 1;")->fetchAll();
if(isset($featured_article[0])) {
  foreach ($featured_article as $featured) {
    echo $featured['body'];
    }
}

Just different table and fields, but the logic stays the same.

So, maybe you have more databases and you use the wrong one?
 
I can't see anything wrong in your code - more, I even tested it and it works.

The code I used to test:
PHP:
$featured_article = $SQL->query("SELECT `title`, `body` FROM `myaac_news` ORDER BY `date` DESC LIMIT 1;")->fetchAll();
if(isset($featured_article[0])) {
  foreach ($featured_article as $featured) {
    echo $featured['body'];
    }
}

Just different table and fields, but the logic stays the same.

So, maybe you have more databases and you use the wrong one?
Same happened with newstickers but i managed to show them some minutes ago, but they display in a bad way, i think its related to my latestnews.php and the layout.
Thanks for your reply, very apreciated.
 
Back
Top