Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
How can I toggle Bootstrap checkbox in PHP Foreach Statement using jQuery and Pass it the data as an Ajax Request to the endpoint

Find blow the source code please, How can I toggle Bootstrap checkbox in PHP For each Statement using jQuery and Pass it the data as an Ajax Request to the endpoint. When I checked any checkbox it will toggle me the value of that particular I toggle.

 <?php

    if(isset($_GET['page']))
    {
    $page=$_GET['page'];
    }
    else
    {
    $page = 1;
    }
    
    $limit = 25;
    
    $offset=($page-1)*$limit;
    
    $select_stmt=$con->prepare("SELECT * FROM plan ORDER BY id DESC LIMIT ?,? ");
    $select_stmt->bindValue(1, $offset, PDO::PARAM_INT);    
    $select_stmt->bindValue(2, $limit, PDO::PARAM_INT); 
    $select_stmt->execute();
    $rows=$select_stmt->fetchAll(PDO::FETCH_ASSOC);
    
    foreach ($rows as $row) {
?>
    <tr>
      <td><?php echo $row['title']; ?></td>
      <td>
        <?php

          $query = "SELECT * FROM networks WHERE network_id=:myplan_id";
          $statement = $con->prepare($query);
          $statement->execute([
            ':myplan_id' => $row['network_id']
          ]);
          $title = $statement->fetch(PDO::FETCH_ASSOC);

          echo $title['title'];

        ?>
      </td>
      <td>
          <?php
            $money = Money::of($row['amount'], 'NGN');
            echo $money->formatTo('en_US');
          ?>
      </td>
      <td>
        <?php
            if ($row['status'] == NULL || $row['status'] == 'active') {
        ?>
          <span class="badge bg-success">Active</span>
        <?php
            }else{
        ?>
          <span class="badge bg-danger">In Active</span>
        <?php
            }
        ?>
      </td>
      <td><?php echo $row['created_at']; ?></td>
      <td>
        <div class="form-check form-switch">
          <input class="form-check-input" type="checkbox" role="switch" id="checkbox<?= $row['id']?>">
        </div>enter code here
      </td>
      <td><a href="edit_plan.php?id=<?php echo $row['id']?>" class="btn btn-success"><i class="fa fa-edit"></i> </a></td>
    </tr>
<?php
    }
          ?>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!