0

I am echoing to my website possible checkbox values that are in a table JobChoose like this

<?php
$got = mysql_query("SELECT * FROM JobChoose");
$checkbox = '';
while ($row = mysql_fetch_assoc($got)) {
    $checkbox .= '<li><input type="checkbox" id="Jobselect" name="Job" value = "' . $row['Job'] . '">' . $row['Job'] . '</input></li>';
} ?> 

<?php echo $checkbox;?> 

When a checkbox is selected is inserted to a customer info. But when i am trying to to get selected value back nothing appears when i click to a customer although it appears in mysql database

echo "<td align='center' class='hidden'>". $row["Job"] ."</td>";

<script type='text/javascript'>
    $('#tabled').on('click', 'tr', function () {
        $("#Jobselect").val($(this).find("td").eq(19).html());
    });
</script>

Also i fetch search results into a table like this

<?php


  $sql = "SELECT * FROM new_record WHERE surname LIKE
 '%".$_POST["search"]."%' or name LIKE'%".$_POST["search"]."%' or
 barcode LIKE'%".$_POST["search"]."%'";    $result =
 mysqli_query($connect, $sql);    if(mysqli_num_rows($result) > 0)    {


     while($row = $result->fetch_assoc()){

                       echo "<tr>";
                        echo "<td >". $row["id"] ."</td>";
                       echo "<td>". $row["surname"] ."</td>";
                      echo "<td>". $row["name"] ."</td>";
                      echo "<td>". $row["company_name"] ."</td>";
                      echo "<td>". $row["firm"] ."</td>";
                        echo "<td>". $row["address"] ."</td>";
                      echo "<td>". $row["town"] ."</td>";
                        echo "<td>". $row["tk"] ."</td>";
                          echo "<td>". $row["country"] ."</td>";
                          echo "<td>". $row["telephone"] ."</td>";
                         echo "<td>". $row["fax"] ."</td>";
                           echo "<td>". $row["mobile"] ."</td>";
                             echo "<td>". $row["mail"] ."</td>";
                               echo "<td>". $row["web_site"] ."</td>";
                               echo "<td>". $row["barcode"] ."</td>";
                         echo "<td>". $row["visitors"] ."</td>";
                             echo "<td align='center' class='hidden'>". $row["custId"] ."</td>";
                           echo "<td align='center' class='hidden'>". $row["trn_date"] ."</td>"; echo "<td align='center' class='hidden'>".
 $row["HowToFindUs"] ."</td>"; echo "<td align='center'
 class='hidden'>". $row["Job"] ."</td>";
                       echo "</tr>";
       }    }    else    {  
       echo 'Data Not Found';    }    ?>
vimuth
  • 5,064
  • 33
  • 79
  • 116
Aristain
  • 11
  • 6
  • Also all the checkboxes have the same `id="Jobselect"` Thats just illegal HTML code as an `id` on a page must also be UNIQUE of it will only see the last one. Also javascript wont like that – RiggsFolly May 02 '16 at 11:05
  • @RiggsFolly is inserting to db Array in info insted of the value – Aristain May 02 '16 at 11:05
  • `$("#Jobselect")` will only know about the LAST ` – RiggsFolly May 02 '16 at 11:08
  • @Kaushalshah checked="checked" is making all values that appear on checkox list checked – Aristain May 02 '16 at 11:37
  • you have set atribute checked in jquery if else condition like this if($(this).is(':checked')){( this ).attr( 'checked', true ); } – Kaushal shah May 02 '16 at 11:46