Need help with Dynamic select rows HTML/PHP/SQL

Good day

i need some help with my code. I am trying to add a dynamic checkbox to a dynamic row from data from SQL. when you click the checkbox and submit i want to show additional information. small sample of my code. I realy dont know where to begin

$sql = "SELECT  id,code,item,measure,size  FROM stores WHERE item LIKE '$term%'";
               $result = mysqli_query($link, $sql);
             $no 	= 1;
	$total 	= 0;
		while ($row = mysqli_fetch_array($result))
            echo "<tr>";
            echo "<td>$no</td>";
            echo "<td>{$row['id']}</a></td>";
	    echo "<td>{$row['code']}</td>";
		echo "<td>{$row['item']}</td>";	
            echo "<td>{$row['measure']}</td>";   
            echo "<td>{$row['size']}</td>";
            echo '<td> <input type="checkbox" name="submit[]"></td>';
            echo "</tr>";
		}else {
                  echo 'no data';

You begin by putting the ID of the data into the checkbox, otherwise you don’t know which details to fetch.

Thanks for the hint. but i thought the name= … is the ID. how do i get a unique id for each checkbox since the checkbox is created with a loop ?

any help is appreciated

Well, name is the ID of the checkboxes in the POST data (e.g. $_POST['submit']) but the IDs of the entries come from the checkboxes’ values (otherwise each checked checkbox will submit ‘on’ as value, which doesn’t help).

each row has an ID …

thanks for the help, i managed to get it fixed by following your advice

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.