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

  • Home
  • SEARCH
  • 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 6754263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:15:33+00:00 2026-05-26T13:15:33+00:00

On my website get articles with PHP query, something like $sql – (SELECT *

  • 0

On my website get articles with PHP query, something like

$sql - ("SELECT * FROM articles WHERE showing=0");

most important thing here is showing=0 I’ll explain why latter on.

I was thinking of adding a check box that will do the following:
If user checks the check box it will change showing=1 and if it is unchecked showing=0.

How would I make it so 1) it remembers if user has or hasn’t clicked a check box. So every time user visits the website the check box is on or off depending on what user did before.
2) refresh page to show new results if for example showing=0 changed to showing=1 ?

  • 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-05-26T13:15:33+00:00Added an answer on May 26, 2026 at 1:15 pm

    If you care at all about performance, it’s vitally important to know how big the articles table could get, and how it’s indexed. If the articles table is small enough that the other steps of generating the webpage overwhelm the cost of two queries (which you may be able to parallelize), simply generate both lists, drop in two divs, and write client-side JavaScript to show the specified div only when the checkbox is checked or unchecked. Something like

    <script type="text/javascript">
        function updateArticlesList() {
            var box = document.getElementById("ckart");
            if (box.checked) {
                document.getElementById("article0").style.visibility = "collapse";
                document.getElementById("article1").style.visibility = "visible";
            } else {
                document.getElementById("article0").style.visibility = "visible";
                document.getElementById("article1").style.visibility = "collapse";
            }
        }
    </script>
    <input id="ckart" type="checkbox" onclick="updateArticlesList()">Switch articles list</input>
    

    should take care of question 2 at least. If the articles table is big and slow to query, you have to go a completely different route, and fill in the missing div only if the user actually clicks on the checkbox. In this case, you need to add AJAX calls to the updateArticlesList function.

    On the other hand, question 1 is an entirely different question. I’m going to have to assume that you have some way to know who the current user is whenever you generate a page, otherwise it’s meaningless to try to speak of a “what the user did before.” But, with the code above, the only thing you need to do is to set the initial values of the visibility for divs article0 and article1, and the visibility of checkbox ckart. AJAX comes in on the question of saving the user’s settings back to the server. Your best bet is to add a URL to the server (I have far more Django experience, so my first instinct is a urls.py entry, even though I know that doesn’t apply to PHP) such that a post back of the string “0” or “1” causes the settings to be saved in the user’s profile. On the next page serve, if the user’s article visibility setting is 0, then div article0 is visible, article1 is collapsed, and ckart is unchecked. If the user’s article visibility setting is 1, then article0 is collapsed, article1 is visible, and ckart is checked.

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

Sidebar

Related Questions

I've created some if / else statements to get name from url like http://website.com/page.php?name=Love
I have articles on my website which I would like to get corrected and
I get a script from a website to put it into my website, but
i get the webpage content from an external website using ajax but now i
I just get a script from a website to put it on my own
How can I get a PHP function go to a specific website when it
I have a website where users can post their articles. I would like to
All I want is to get the website URL. Not the URL as taken
I have a website that I get the below error on whenever I navigate
I have been trying to days now to get this website completed ... however,

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.