Jump to content

cms error messages


cactus

Recommended Posts

Hi,

 

I am creating a cms using php and my sql for my website. I have managed to create the majority of it but am having trouble added a menu on each page.

 

It appears on the homepage with the following code:

 

      <ul id="headlines">

 

<?php foreach ( $results['articles'] as $article ) { ?>

 

        <li>

          <h2>

<a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a>

          </h2>

        </li>

 

<?php } ?>

 

      </ul>

 

Once I click on a selection from the menu it takes me to the correct article but there is no menu now.

 

If I try to copy and paste the code from homepage into my viewArticle file it gives me the error messages 'undefined index articles on line 6' and 'invalid argument supplied for for each'.

 

This is the viewArticle code after I pasted in the code from homepage:

 

      <ul id="headlines">

 

<?php foreach ( $results['articles'] as $article ) { ?>

 

        <li>

          <h2>

<a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a>

          </h2>

        </li>

 

<?php } ?>

 

      </ul>

 

      <h1 style="width: 75%;"><?php echo htmlspecialchars( $results['article']->title )?></h1>

      <div style="width: 75%;"><?php echo $results['article']->content?></div>

 

 

I would really appreciate anybody helping me figure out how I can add the menu onto the viewArticle page.

 

Thanks in advance :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.