title: Saving the selected rows by checkbox to database in php
body: <p>I have a query to display all the records of the ebooks table from the database. </p>
  
  <p>I displayed it in a table with a checkbox from the first column. </p>
  
  <p>I'm trying to save the rows from the selected checkbox in the table width the Name of School but I don't have any idea. </p>
  
  <p>I'm just a beginner in php, any help is appreciated. Here is my codes:</p>
  
  
  
  <p>HTML codes:</p>
  
  <p>
      
      
  
  <pre><code>$result1 = mysql_query("SELECT * FROM school GROUP BY SCHOOL_NAME");
  
  while($row1=mysql_fetch_array($result1)) {
  ?&gt;
      &lt;option&gt;&lt;?php echo $row1['SCHOOL_NAME'];?&gt;&lt;/option&gt;
  &lt;?php } ?&gt;
  &lt;/select&gt;
  
  &lt;table class="table table-striped table-hover table-bordered datatable"&gt;
      &lt;thead style="background: #a83535; color: black;"&gt;
      &lt;tr&gt;
          &lt;th style="width: 50px;"&gt;&lt;/th&gt;
          &lt;th style="color: #3b3b3b;"&gt;Ebook Title&lt;/th&gt;
          &lt;th style="color: #3b3b3b;"&gt;Category&lt;/th&gt;
          &lt;th style="color: #3b3b3b;"&gt;File Name&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;?php
      $result = mysql_query("SELECT * from ebooks ORDER BY EBOOK_TITLE");
      $count = mysql_num_rows($result);
      while($row=mysql_fetch_array($result)) {
      ?&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;center&gt;&lt;input type="checkbox" name="check[]" &gt;&lt;/center&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;input type="" name="ebookname[]" value="&lt;?php echo $row['EBOOK_TITLE'];?&gt;"&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="" name="ebookcategory[]" value="&lt;?php echo $row['EBOOK_CATEGORY'];?&gt;"&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="label" name="ebookfilename[]" value="&lt;?php echo $row['EBOOK_FILENAME'];?&gt;"&gt;&lt;/label&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;?php } //end of while loop ?&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;button type="submit" class="btn btn-hg btn-primary" name="AddEbooks"&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>I want to save the rows selected by the checkbox to database:</p>
  
  <ul>
  <li>Table: <code>school_management</code></li>
  <li>Columns: <code>ID_NUMBER</code>, <code>SCHOOL</code>, <code>EBOOK</code>, <code>FILE_NAME</code>, <code>DATE_ASSIGN</code></li>
  <li><code>Values (from the HTML table to database): ('','$school_ebook','$ebookname','$ebookfilename','')</code></li>
  </ul>
  
  <p>Here is the screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/BFp6Z.png" alt=""></p>