I have multiple small HTML tables generated by PHP on a single page, each with a unique <table id="">
. The data in these tables corresponds to entries in a MySQL table with matching IDs.
What I am looking for is to automatically highlight the values in each HTML table that match the data in the corresponding row of the MySQL table with the same ID.
Instead of using checkboxes and manual selection, I need this highlighting process to happen seamlessly without any user interaction. Typically, with checkboxes, the functionality would resemble something like this: https://jsfiddle.net/zt54jqtL/ Thanks!!
<div>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="checkbox" name="SelectAll" class="all" />All</label>
<label>
<input type="checkbox" name="2" class="selector" />2</label>
<label>
<input type="checkbox" name="7" class="selector" />7</label>
<label>
<input type="checkbox" name="7" class="selector" />7</label>
</form>
PHP code:
<?php
$conn=mysqli_connect("localhost","root","","Mdata");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
function print_tableX ($conn, $id) {
$sql = "SELECT Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8 FROM tableA";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table id='$id'>";
while($row = $result->fetch_assoc()) {
echo '<tr><td>' . join('</td><td>', $row) . "</td></tr>\n" ;
}
echo "</table>";
}
}
$result = $conn->query("SELECT sID from tableB");
while ($row = $result->fetch_assoc()) {
print_tableX ($conn, $row['sID']);
}
?>