Here is what I tried to do. Please read through as I'll try best to explain my issue as I'm kinda new here.
(1) I have check boxes dynamically created and tried assigning check box name same as one of the data records in the SQL database. i.e there is a table column with the name 'sbstart' and I tried assigning the values of this table row to check boxes as check box name. example, sbstart has 3 rows which contains 1,2,3, so I tried assigning 1,2,3 as check box values. Here's the code for that.
echo "<table cellpadding='2' class='tablet' cellspacing='0'>";
echo
"<tr>
<th class='tbldecor8'></th>"
."<th class='tbldecor2'>"."Starting Cheque No"."</th>"
."<th class='tbldecor3'>"."Ending Cheque No"."</th>"
."<th class='tbldecor4'>"."Total No of Cheques remaining"."</th>"
."<th class='tbldecor5'>"."Cheque Type"."</th>"
."</tr>";
while ($reca = mysqli_fetch_array($result))
{
if($reca['sbstart'] != "" && $reca['sbend'] !="") {
$cxVal = $reca['sbstart'];
echo "<tr>";
echo "<td class='tbldecor1'><input type='checkbox' name='$cxVal'>$cxVal</td>";
echo "<td class='tbldecor2' style='text-align:center'>".trim($reca["sbstart"])."</td>";
echo "<td class='tbldecor3' style='text-align:center'>".trim($reca["sbend"])."</td>";
echo "<td class='tbldecor4' style='text-align:center'>".trim($reca["totsb"])."</td>";
echo "<td class='tbldecor5' >SmithKline Beecham (Consumer)</td>";
echo "</tr>";
}
}
echo "<tr class='tbldecor6'></tr>";
echo "</table>";
(2) Please read. Im coming to my issue. Secondly I wanted to check when user submits the form what values are selected through check boxes, get them and delete them. In order to do that to understand what options user has checked I used the following and it always giving 'No' as output.
if(isset($_POST['submit']))
{
if(isset($_POST['$cxVal'])){echo 'Yes';}else{ echo 'No';}
}
Well if you have a better idea/ correct ways of doing this please share. Thanks.
EDIT:
<html>
<form with PHP SELF......>
<div><?php
echo "<table cellpadding='2' class='tablet' cellspacing='0'>";
echo
"<tr>
<th class='tbldecor8'></th>"
."<th class='tbldecor2'>"."Starting Cheque No"."</th>"
."<th class='tbldecor3'>"."Ending Cheque No"."</th>"
."<th class='tbldecor4'>"."Total No of Cheques remaining"."</th>"
."<th class='tbldecor5'>"."Cheque Type"."</th>"
."</tr>";
while ($reca = mysqli_fetch_array($result))
{
if($reca['sbstart'] != "" && $reca['sbend'] !="") {
$cxVal = $reca['sbstart'];
echo "<tr>";
echo "<td class='tbldecor1'><input type='checkbox' name='$cxVal'>$cxVal</td>";
echo "<td class='tbldecor2' style='text-align:center'>".trim($reca["sbstart"])."</td>";
echo "<td class='tbldecor3' style='text-align:center'>".trim($reca["sbend"])."</td>";
echo "<td class='tbldecor4' style='text-align:center'>".trim($reca["totsb"])."</td>";
echo "<td class='tbldecor5' >SmithKline Beecham (Consumer)</td>";
echo "</tr>";
}
}
echo "<tr class='tbldecor6'></tr>";
echo "</table>";
?>
<input type="submit" name="del" id="del" value="Delete">
</div>
</form>
</html>