One list instead of one article?

Can anybody help me to sort this out.

I have an php/mysql site. In the left sidebar I got a menu. When you click a link in the menu, the article that the link points to will be displayed in the content area. If you click another link in the same menu, the article that that link points to will be displayed in the content area by replacing the former article etc.

Two articles will never be shown simultaneously in the content area.

This works just fine.

Now, I want a article archive too. So I made a horizontal menu and here’s where the problem occurs. If I click the link “Archive” in the horizontal menu, a list of articles will be displayed in the content area. This is good. The problem is that it will be displayed below the article in the content area. I want it to replace the article.

How do I achieve that?

:)It’s 2.40 PM here in Sweden

I think this should work as expected:


include 'connect.php';
if (isset($_GET['arkiv'])){
    $result = mysqli_query($link, 'SELECT id,namn,artikel FROM artiklar ORDER BY datum DESC LIMIT 10');
    if (!$result){
        $error = 'Error fetching jokes: ' . mysqli_error($link);
        include 'error.html.php';
        exit();
    }
    while ($row = mysqli_fetch_array($result)){
        echo("<a href=\\"index.php?id=" . $row[0] . "\\">" . $row[1] . "</a> ");
    }
}
else{
    if (isset($_GET['id'])){
        $result = mysqli_query($link, "SELECT namn,artikel FROM artiklar WHERE id= " . $_GET['id']);
        if (!$result){
            $error = 'Error fetching morons: ' . mysqli_error($link);
            include 'error.html.php';
            exit();
        }
        while ($row = mysqli_fetch_array($result)){
            echo"<h3>" . ($row[0]) . "</h3>";
            echo ($row[1] . "<br />");
        }
    }
    else{
        $result = mysqli_query($link, 'SELECT namn,artikel FROM artiklar ORDER BY datum DESC LIMIT 1'); 
    }
    while ($row = mysqli_fetch_array($result)){
        echo"<h3>" . ($row[0]) . "</h3>";
        echo ($row[1] . "<br />");
    }
}

No hints?

If you are using same file/script/page to display the article and the archive then make two different pages for single article and archive display. Or if you want to display both in the same page/file then have a condition there. If it is archive to display then hide the article.

BTW, which article is displayed when you click in the Archive? Because to display an article in the page you need an article ID.

:injured:and its hot - 30 degrees celsius

Off Topic:

It is almost End of Day here. :smiley:

6:40 PM here :stuck_out_tongue:

:)Thank you very much! Have a nice day!

Here’s some details. First the link that shows the article archive in the content area

<a href="index.php?arkiv=arkiv" class="nav" name="arkiv" id="arkiv">Artikelarkiv</a>

:

The link is part of a horizontal menu. Here’s the php code that shows the article archive in the content area:

if (isset($_GET['arkiv']))
{
include 'connect.php';

$result = mysqli_query($link, 'SELECT id,namn,artikel FROM artiklar ORDER BY datum DESC LIMIT 10');
if (!$result)
{
$error = 'Error fetching jokes: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
echo("<a href=\\"index.php?id=" . $row[0] . "\\">" . $row[1] . "</a> ");
}

}

This works just fine. Now I got a vertical menu too. If I clink on any link in that menu the article that the link points at will replace anything in the content area. So far no problem.
And now to the problem. I want the page to display something in the content area regardless of any clicking on links.

include 'connect.php';

if (isset($_GET['id']))
{
	
$result = mysqli_query($link, "SELECT namn,artikel FROM artiklar 
WHERE id= " . $_GET['id']);
if (!$result)
{
$error = 'Error fetching morons: ' . mysqli_error($link);
include 'error.html.php';
exit();
}

while ($row = mysqli_fetch_array($result))
{
echo"<h3>" . ($row[0]) . "</h3>";
echo ($row[1] . "<br />");
}

}
else
{
$result = mysqli_query($link, 'SELECT namn,artikel FROM artiklar 
 ORDER BY datum DESC LIMIT 1');	
}
while ($row = mysqli_fetch_array($result))
{
echo"<h3>" . ($row[0]) . "</h3>";
echo ($row[1] . "<br />");
}

So if the user did not click on any link the page will simply display the latest added article in the content area. Thats good. The problem is that if that is the case and the user clicks a link the article that the link points to will be displayed together with latest added article in the content area. I guess I need some kind of if statement?

Thank you very much for taking time!

Yes, I am trying to display both in the same page. How do I hide the article?