News Title not Selected

Detox

Member
Jul 24, 2010
365
24
For some odd ball reason my news articles are not being selected when they are being echo out with the titles.

I've been trying to get help from all different sort of community but nothing seems to be working.

xnwzuv.jpg


Code that is being used to echo that out.

PHP:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id'].",selected'>";
}
?>
 

Seriosk

Programmer;
Oct 29, 2016
256
105
For some odd ball reason my news articles are not being selected when they are being echo out with the titles.

I've been trying to get help from all different sort of community but nothing seems to be working.

xnwzuv.jpg


Code that is being used to echo that out.

PHP:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id'].",selected'>";
}
?>

Your classes are formatted wrong

Your code:
Code:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id'].",selected'>";
}
?>

Correct code:
Code:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id']." selected'>";
}
?>
See the difference? The class attribute is allowed multiple classes but are separated by a space, not a ,
If this doesn't fix it then ensure you have the css code for class "selected"
 

Detox

Member
Jul 24, 2010
365
24
Your classes are formatted wrong

Your code:
Code:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id'].",selected'>";
}
?>

Correct code:
Code:
<?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id']." selected'>";
}
?>
See the difference? The class attribute is allowed multiple classes but are separated by a space, not a ,
If this doesn't fix it then ensure you have the css code for class "selected"
That doesn't fix it. I know selected is in my CSS fine because when I used this code.

PHP:
<?php
    {
    for ($i = 0; $i < 6; $i++)
        {
            $sectionName = "";
            $sectionCutoffMax = 0;
            $sectionCutoffMin = 0;
      
            switch ($i)
            {
                    case 0:
              
                            $sectionName = 'Today';
                            $sectionCutoffMax = time();
                            $sectionCutoffMin = time() - 86400;
                            break;
                      
                    case 1:
              
                            $sectionName = 'Yesterday';
                            $sectionCutoffMax = time() - 86400;
                            $sectionCutoffMin = time() - 172800;
                            break;
                      
                    case 2:
              
                            $sectionName = 'This week';
                            $sectionCutoffMax = time() - 172800;
                            $sectionCutoffMin = time() - 604800;
                            break;
                      
                    case 3:
              
                            $sectionName = 'Last week';
                            $sectionCutoffMax = time() - 604800;
                            $sectionCutoffMin = time() - 1209600;
                            break;
                      
                    case 4:
              
                            $sectionName = 'This month';
                            $sectionCutoffMax = time() - 1209600;
                            $sectionCutoffMin = time() - 2592000;
                            break;
                      
                    case 5:
              
                            $sectionName = 'Last month';
                            $sectionCutoffMax = time() - 2592000;
                            $sectionCutoffMin = time() - 5184000;
                            break;
            }
      
            $q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax .  " ORDER BY published DESC";
            $getArticles = mysql_query($q);
            if (mysql_num_rows($getArticles) > 0)
            {
                    echo '<h2>' . $sectionName . '</h2>';
              
                    while ($a = mysql_fetch_assoc($getArticles))
                    {
                        if($a['id'] == $_GET['id'])
                        {
                        echo '' . $a['title'] . '&nbsp;&raquo;';
                        }
                        else
                        {
                        echo '<li><a href="/index.php?url=news&id=' . $a['id'] . '">' . $a['title'] . '&nbsp;&raquo;</a></li>';
                        }
                    }
            }
        }
    }
?>

I get this

288mheb.png


With the spacing all messed up a little compare to my other images

But when I used this code (original)

PHP:
<?php

$subNavigatorID = 2;
require_once ('includes/subnavi.php');

?>
                    </ul>
                </div>
            </div>
            <div id="container">
            <div id="content" style="position: relative" class="clearfix">
            <div id="column1" class="column">
            <div class="habblet-container ">
            <div class="cbb clearfix default ">
            <h2 class="title">News</h2>
            <div id="article-archive">
               </ul>           

<?php
    for ($i = 0; $i < 6; $i++)
    {
        $sectionName = '';
        $sectionCutoffMax = 0;
        $sectionCutoffMin = 0;
      
        switch ($i)
        {
            case 0:
          
                $sectionName = 'Today';
                $sectionCutoffMax = time();
                $sectionCutoffMin = time() - 86400;
                break;
              
            case 1:
          
                $sectionName = 'Yesterday';
                $sectionCutoffMax = time() - 86400;
                $sectionCutoffMin = time() - 172800;
                break;
              
            case 2:
          
                $sectionName = 'This week';
                $sectionCutoffMax = time() - 172800;
                $sectionCutoffMin = time() - 604800;
                break;
              
            case 3:
          
                $sectionName = 'Last week';
                $sectionCutoffMax = time() - 604800;
                $sectionCutoffMin = time() - 1209600;
                break;
              
            case 4:
          
                $sectionName = 'This month';
                $sectionCutoffMax = time() - 1209600;
                $sectionCutoffMin = time() - 2592000;
                break;
              
            case 5:
          
                $sectionName = 'Last month';
                $sectionCutoffMax = time() - 2592000;
                $sectionCutoffMin = time() - (60 * 60 * 24 * 365);
                break;
        }
      
        $q = "SELECT * FROM cms_news WHERE published >= " . $sectionCutoffMin . " AND published <= " . $sectionCutoffMax .  " ORDER BY published DESC LIMIT 50";
        $getArticles = mysql_query($q);

        if (mysql_num_rows($getArticles) > 0)
        {
                echo '<h2>' . $sectionName . '</h2>
                <ul>';

            while ($a = mysql_fetch_assoc($getArticles))
            {
?>
    <li>
    <?php
if($news_id !== $a['id'])
{
    echo "<a href='".$path."/news/".$a['id']."'  class='article-".$a['id']." select'>";
}
?>
    <?php echo $a['title'];?>&nbsp;&raquo;</a>
    <?php if($news_id !== $a['id']){ echo"</a>"; } ?></li>
    <?php }
echo '
</ul>
';
        }
    }

?>

I get this cleaner look without the selected

xnwzuv.jpg


I hope all of this is making sense.
 

Users who are viewing this thread

Top