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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:25:41+00:00 2026-06-16T14:25:41+00:00

Possible Duplicate: handling checked checkboxes PHP i have this problem. I have a webpage

  • 0

Possible Duplicate:
handling checked checkboxes PHP

i have this problem. I have a webpage that show car registration number and it’s violation. And we can change the status of the violation from 1=not treated to 2=treated. I want to use multiple check box to choose which car registration status that i want to change
here’s the screenshot of my web

)

how i change the status of both car registration number ?
here’s my webpage code

 <div id="content">
    <div class="content_item">
    <?php
       $con = mysql_connect("localhost","fpjarmul","fpjarmul");
        if (!$con)
          {
          die('Could not connect: ' . mysql_error());
          }

        mysql_select_db("fpjarmul", $con);

        $query = "SELECT * FROM laporan WHERE status = '1'";
        $result = mysql_query($query);

        while($row = mysql_fetch_array($result, MYSQL_ASSOC))
        {?>
            <form action="ubahdata.php" method="post">
                <input type="checkbox" name="idlaporan" value="<?php echo $row['idlaporan'] ?>" /><?php echo "ID : {$row['idlaporan']}" ?><br />
                <?php echo  "Nomor Polisi : {$row['platkendaraan']} <br>" .
                            "Status : {$row['status']} <br>" . 
                            "Tanggal Laporan : {$row['tanggallapor']} <br><br>"; ?>

        <?php   
        } 
        ?>  
                <input type="submit">
            </form>

and here’s my script

 <?php include 'header.php'; ?>
 <?php
$con = mysql_connect("localhost","fpjarmul","fpjarmul");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

 mysql_select_db("fpjarmul", $con);

 $sql=("UPDATE laporan set status='2' where idlaporan='$_POST[idlaporan]'");

 if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
?> 
 <?php include 'footer.php'; ?>
  • 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-16T14:25:42+00:00Added an answer on June 16, 2026 at 2:25 pm

    Please try the following approach:

    1. Change the checkbox ‘name’ as ‘idlaporan[]’ (<input type=”checkbox” name=”idlaporan[]” )
    2. After form submit, selected check box values will be present in the Server side array $_POST[‘idlaporan’]
    3. Use a foreach loop to update values in database.

      foreach ($_POST['idlaporan'] as $idlaporan) {
      
          $sql=("UPDATE laporan set status='2' where idlaporan='$idlaporan'");    
          if (!mysql_query($sql,$con)) {
             die('Error: ' . mysql_error());
          }
          echo "1 record added<br/>";    
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Show line number in exception handling Can someone please tell me how
Possible Duplicate: When and how should I use exception handling? I have seen that
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Handling a Click for all controls on a Form I have a
Possible Duplicate: JavaScript Exception Handling I have a web application where 100% of the
Possible Duplicate: Using global exception handling with “setUncaughtExceptionHandler” and “Toast” I have implemented UncaughtExceptionHandler
Possible Duplicate: Handling very large numbers in Python I have a python function to
Possible Duplicate: Error handling in C code Let's say you have a function: int
Possible Duplicate: Failing to upload file with curl in heroku php app After handling

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.