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 8577119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:05:22+00:00 2026-06-11T20:05:22+00:00

good morning programers, I have this small code which content a news control panel

  • 0

good morning programers,
I have this small code which content a news control panel and I made a submit button there to active or inactive the news row so if I click on this button it should change if it’s active it will be inactive it worked but there’s something wrong there when I click on item one it updates the last on the table not the first on as it should do.
here is the code that I use

<?php
$getNewsData="select * from news";
    $QgetNewsData=$db->query($getNewsData)or die($db->error);
    $count=mysqli_num_rows($QgetNewsData);
while($newsRow = mysqli_fetch_array($QgetNewsData)) {
$getActivityStatus=$newsRow['news_activity']; 
    switch($getActivityStatus){
    case 1: echo"<input style='color:red; font-weight:bold; background:none; border:0;' name='inactive' type='submit' value='تعطيل' /><input name='inActive' type='hidden' value='".$newsRow['news_id']."'/>"; 
    break; 
    case 0: echo"<input style='color:green; font-weight:bold; background:none; border:0;' name='active' type='submit' value='تفعيل' /><input name='Active' type='hidden' value='".$newsRow['news_id']."'/>"; break;}
    }
if(isset($_POST['inactive'])){
            $inActive=$_POST['inActive'];
            echo $inActive;
        $updateStatus="UPDATE news SET news_activity=0 WHERE news_id='".$inActive."' ";
        $QupdateStatus=$db->query($updateStatus)or die($db->error);
        if($QupdateStatus){ 
            }
        }

        if(isset($_POST['active'])){
            $Active=$_POST['Active'];
            echo $Active;
        $updateStatus="UPDATE news SET news_activity=1 WHERE news_id='".$Active."' ";
        $QupdateStatus=$db->query($updateStatus)or die($db->error);
        if($QupdateStatus){
        header("Location:CpanelHome.php?id=7"); 
            }
        }
    ?>

please any idea to solve this problem.
Thanks,
regards

  • 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-11T20:05:23+00:00Added an answer on June 11, 2026 at 8:05 pm

    You create a lot of <input name='inActive' and <input name='Active' fields. Please note that all of them are submitted when any submit button is clicked. Easiest solution I can think of is to put each pair of submit button and hidden input into separate <form>.

    NOTES

    Your code is pretty bad, you should consider making some improvements. For starters:

    • Please format your code correctly or find an editor that will do it for you.
    • Please validate POST data before using them in a query.
    • Please don’t glue queries from strings, instead use prepared statements
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Morning, I have copied this code from somewere <script type=text/javascript> $(function() { setInterval(rotateImages(),
Good morning! We have a SVN-Repository, which holds a VS-Solution. In this solution are
Good morning. I've been having this issue for some days and have been lokking
Good Morning/Afternoon all, I have a ASP:grid which displays current versions of Terms and
Good morning. I have an XML file which contains lists of warning and errors
Good Morning, I have an application which allows users to slide values for different
Good morning experts, I have an array which contain integer numbers, and I have
Good morning, I have mysql queries where I would like to calculate percentage of
Good Morning. I have two tables, and one references the other. When I insert
Good morning gang. I have a jQuery Datepicker object that is prepoulated using a

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.