dimanche 3 juillet 2016

Counting Number Of Selected Checkbox & Checking all

Im bringing values from my Database.As you know,sometimes you want to check multiple rows to delete or update.And you would like to know how much did you selected.

What I need is:

-- Number of selected checkboxes -- Checking all checkboxes using one checkbox

Here is how I can loop multiple checkbox es without any function:

if(isset($_POST['Submit']))
{
  echo '<table id="registrations_table_results" border=1  align=center >
  <thead style="font-weight:bold;">
    <tr>
        <td><input type="checkbox" name="checkall"></td>
        <td>#</td>
        <td>Name Surname</td>
        <td>Unique ID</td>
    </tr>
  </thead>';    

    $adsoyad = $_POST['adsoyad'];
    $query = mysqli_query($connect,"select * from kullanicilar where adsoyad like '%$adsoyad%'");


    while ($read = mysqli_fetch_array($query))
    {       
        $id = $read['ID'];
        $adsoyad = $read['adsoyad'];
        $tc = $read['tc'];

        echo '
            <tr>
                <td><input type="checkbox" name="check"></td>
                <td>'.$id.'</td>
                <td>'.$adsoyad.'</td>
                <td>'.$tc.'</td>
            </tr>
            ';
    }
  }

Here how looks like:

problem At this point as you can see,there are checkbox es near each result when clicked the search button.And 1 at the table header to check all.I have tried multiple of functions there but they seemed to not work.I decided to copy-paste the work of mine here ,So it would be better to fit the function I needed here.




Aucun commentaire:

Enregistrer un commentaire