Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:22:19+00:00 2026-06-13T23:22:19+00:00

All, I’m building a small PHP site using an MVC pattern. Inside my Controller,

  • 0

All,

I’m building a small PHP site using an MVC pattern. Inside my Controller, I have an array of articles that I want to send to the View page. However, I want the articles to appear one at a time in the View, and only change to the next one when the user clicks on one of several buttons. One button just allows the user to see the next article, other buttons allow the user to “grade” or endorse the article (this info is sent back to the controller) and move on to the next article.

How should I do that? The buttons are within a form, and I have Javascript functions attached to each. A simplified version of the code would look like that:

In Controller:

<?php
  $array=array(10,11,12,13,14,15,16);
  $_SESSION['next']=true;
  foreach($array as $a){
    if($_SESSION['next']){
      $_SESSION['next']=false;
      $view=$a;
    }
  }
?>

In View:

<script type="text/javascript">
  function doOne(){}
  function doTwo(){}
</script>
<form class="ReviewArticles" method='POST' accept-charset="UTF-8" action='index.php?action=reviewArticles'>
<p>
  <textarea rows="4" cols="60" name='article' id='article' WRAP=SOFT>
    <?php
      echo $view;
    ?>
  </textarea>
</p>    
<p>
  <button type="button" name='showNext1' id='showNext1' onclick="doOne()" >Show next 1</button>
  <button type="button" name='showNext2' id='showNext2' onclick="doTwo()" >Show next 2</button>
</p>
</form>

I need to send back to the Controller some info to load the next item in the array. I also need to send some other data related to the user “endorsing” of the article, and I want those to take place together (only one button).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:22:20+00:00Added an answer on June 13, 2026 at 11:22 pm

    I would say you have on of two options:

    1) Pull the article information via an AJAX request and display when the users wishes to move onto the next article. This is the best way in my opinion as it guarantees that the user has the most up to date versions of the article.

    2) Store the article information in the page when it is loaded. i.e. write the data into a javascript array, hidden html elements, or whatever your preferred method. When the user hits the button, load the article using the data stored on the page.

    Does that answer your question?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I am building a small site using PHP. In the site, I receive
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
All, I have a form with a MultiValueField that almost works. It uses a
All, I have some script tags that are not working in Wordpress. If I
All, I currently have two projects that are under SourceSafe that I am unable
All of the guides and tutorials that I have read tell me to do
All -- I have these two methods in one of my classes: public static
All I want to do is return the index of the i that is
All, How can I bind the array of drop down list items returned from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.