dimanche 26 janvier 2020

Send more than one information in input

I'm just doing a course exercise, where I need to make a store. When the user click in a option a table appear showing the product options where has a checkbox and a quantity selector. Well I'm trying to find a way to send more than one information through the input or validate the checkbox on the line one with the amount select also in the line one. If I send a checkbox checked on the line 1 and the amount on the line 2 it also works and messes up my database. Any suggestions? Example:

<?php 
require 'connect.php';

$selection= "SELECT * from store_items";
 $result = $obj_conexion->query($selection);

  if($result->num_rows>0){
     echo"<table border='1' align='center'>
      <tr bgcolor='#E6E6E6'>
         <th>Selection</th>
         <th>Item Name</th>
         <th>Price</th>
         <th>Amount</th>
     </tr>";
     while ($row=$result->fetch_array()){
     echo "<tr>
     <td><input type='checkbox' value='".$row["product_id"]."'>
     <td>".$row["product_name"]."</td>";
     echo "<td>".$row["price"]."</td>";
     echo "<td><input type='number' min='0' max='$row[max(amount)]' name='amount_selected'></td></tr>";
     }
 }else
 {
   echo "Error.";
 }


mysqli_close($obj_conexion);
?>



Aucun commentaire:

Enregistrer un commentaire