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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:48:09+00:00 2026-06-11T13:48:09+00:00

I have here a code wherein I have an array of checkbox populated with

  • 0

I have here a code wherein I have an array of checkbox populated with mysql data through a query. I can successfully submit the value of the checked checkbox into a table in a database. But what I want to do is to save it according to the sequence the checkbox was checked by the user. I was told that I can achieve this through javascript but unfortunately, I’m not familiar with javascript at all. If possible, can you provide steps on achieving this through PHP only? If not, can you please guide me on how to achieve this using javascript since I’m a newbie. Here’s my sample code to let you imagine what I’m trying to do..

<?php
require("aacfs.php");
echo"<div align= center >
  <table width=300 border= 1 align= right><tr><th align=center bgcolor=silver><font face=consolas>Choose Itinerary</font></th></tr>
    <tr>
      <td></br>
      <form method=post>"; 


$result=mysql_query(" select * from itinerary group by location");
    $y=mysql_affected_rows();
    for($i=0;$i<$y;$i++)
    {$row=mysql_fetch_array($result);
        $pr=$row['icode'];
        $n=$row['location'];
        $l=$row['btime'];
echo"<table border=1 align=center width=250>
          <tr><td width=15><input name=prod[] type=checkbox value='$pr'></td><td>$n</td></tr>
          </table>";
        $t=$_POST[prod];

        }
echo"</td></tr></table>";

echo"      

    <table width= 664 border= 1  align= left >
    <tr><td height= 282 ><p align= center  class= style77>
<p align= right ><h4>$d</h4></p>
<p align= center ><font face=consolas><b>Itinerary List</b></font></p>
<p align=center><font face=consolas>To change your itinerary list, choose again.</font></p>

<br>
  <center><input name=add  type= submit  value='Add to Itinerary List'></center>
<br>  
<table width=654  border= 1>
  <tr bgcolor = silver align=center>
    <td>Itinerary</td>
    <td>Block Time</td>

 </tr></form>";


 if(isset($_POST['add']))
{           
if(isset($_POST[prod]))
 {  foreach($t as $k)
    {$result=mysql_query("select * from itinerary where icode='$k'");
    $y=mysql_affected_rows();

for($x=0;$x<$y;$x++)
{$row=mysql_fetch_array($result);
        $r=array($row['icode']);
        $n=$row['location'];
        $p=$row['btime'];   



    echo"<form method=post><tr>
<td>$n</td>
<td>$p</td>
 </tr>";

    $a=$_POST[pro];
    $stat1='Not Submitted';

foreach($r as $a=>$l)
{

$kdot=mysql_query("select max(reservno) as 'maxr' from reservation") or die(mysql_error());
$row2=mysql_fetch_array($kdot);
$fi=$row2['maxr'];
mysql_query("insert into location_list(reservno, icode, location, status) values('$fi', '$l', '$n', '$stat1')") or die(mysql_error());
}
}}}

}

Clarifications are most welcome. Hope you can help me! Thanks a lot!

  • 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-11T13:48:10+00:00Added an answer on June 11, 2026 at 1:48 pm

    Got the detection of checked checkbox sequence through this code:

    <script type="text/javascript"> 
    <!--
    
    $(document).ready(function(){
    
        var array = [];
    
    
        $("input[type=button]").click(function(){
        for (var i = 0; i < array.length; i++){  
        if (array[i] == $(this).attr('value')){  
        array.splice(i, 1);  
        }  
        }  
        alert(array.length);
        });
    
    
    
    
        $('input[type="checkbox"]').click(function(){
    
        if ($(this).attr('checked')){
        // Add the new element if checked:  
        array.push($(this).attr('value'));
        //alert(array2.push($(this).attr('name')));
        }
    
        else{ 
        // Remove the element if unchecked:  
        for (var i = 0; i < array.length; i++){  
        if (array[i] == $(this).attr('value')){  
        array.splice(i, 1);
        }
        }
        }
    
    
    
    
    
    
            $("#result").show(function(){
            $(this).val("");
            for (var i = 0; i < array.length; i++){
        $(this).val($(this).val() + " " + array[i]+ "\n");
            }
            });
    
        });
    
    }); 
    //--> 
    </script>
    

    I’m binding it in my checkbox.

    $result=mysql_query(" select * from itinerary group by location");
        $y=mysql_affected_rows();
        for($i=0;$i<$y;$i++)
        {$row=mysql_fetch_array($result);
            $pr=$row['icode'];
            $n=$row['location'];
            $l=$row['btime'];
    echo"<table border=1 align=center width=250>
              <tr><td width=15>
              <input type='checkbox' value='$n -> $l' id='cb1'>
    </td><td>$n</td><td width=4>$l</td></tr>
              </table>";
    

    Then output it in a textarea.

    <textarea name=resulta id='result' style='height:200px; width:350px' disabled='disabled'></textarea>
    

    I can save it in my database through this:

    echo "<form><center><input type=submit name='pindot' value='Gora Men~'></center></form>";
    $val=$_POST['resulta'];
    if (isset($_POST['pindot']))
    {
    $lines = explode("\n", $val);
    
    foreach ($lines as $line) {
        // $line here is a string
        // build a query based on it and execute it
        mysql_query("insert into postflight (sample_lang) values ('$line')") or die(mysql_error());
    
    };
    }
    

    Thank you all for your help! God bless!

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

Sidebar

Related Questions

I have some code here that uses bitsets to store many 1 bit values
I have this code here printf '$request1 = select * from whatever where this
I have this code here, which is intended to allow any type of arguments:
enter code here I have a table on SQL server 2005 with bigint primary
I have this code here, {foreach from=$cart.cartItems item=item name=cart} <div id=cart2Produkt> <p>{if $item.Product.ID} <a
I have some code here which works perfectly in firefox but not in chrome
I have my code here, it works fine from my home, where my user
enter code here I have a ListView that have a different Layout XML for
I have this code here: var Person = (function() { var name; var PersonConstructor
I have some code here to call minizip(), a boilerplate dirty renamed main() of

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.