Currently, in our office website, there is a user input text box. After insertion, the results of the database will be displayed below. There are 4 results for Lot ID, Product, EWSFLOW and Zone
. Among them, only zone is different. I want to make it so that Lot ID, Product and EWSFlow
must be displayed immediately, if the value entered has 5 different zones, the zone must be displayedZone: 1,2,3,4,5
. << The first problem has been solved. Now I try to add checkboxes for each area and the checkbox must appear next to each area. But currently, the checkbox is showing at the top. Additionally, the number of checkboxes must be the same as the number of regions. Assuming that the inserted value has 5 fields, in addition to this 5 checkboxes must be displayed (example: field: [checkbox] 1).
Checkbox shown at top
echo "<table id='corwafer'>"; $arr = array(); while ($row = mysqli_fetch_assoc($result1)) { $field1name = $row["lotid"]; $field2name = $row["product"]; $field3name = $row["ewsflow"]; $field4name = $row["zone"]; $key = $field1name + ":" + $field2name + ":" + $field3name; if (!in_array($key, $arr)){ echo "<tr>"; echo "<th >Lot ID:</th>"; echo "<td >$field1name</td>"; echo "</tr>"; echo "<tr>"; echo "<th>Product:</th>"; echo "<td>$field2name</td>"; echo "</tr>"; echo "<tr>"; echo "<th>EWSFLOW: </th>"; echo "<td>$field3name</td>"; echo "</tr>"; array_push($arr, $key); } echo "<tr>"; echo "<th>Zone:</th>"; echo "<input type='checkbox' name='chkzone' value='chkzone'>"; echo "<td>$field4name</td>"; echo "</tr>"; } echo "</table>";
You can change the query and use MySQL's
GROUP BY
feature. Below is the query. Ignore any spelling errors.GROUP_CONCAT() The function returns a string containing the concatenated non-NULL values from the group.
GROUP BY statement groups rows with the same value into summary rows, such as "Find the number of customers per country."
You can define an array and put
lotid
,product
andewsflow
into it and combine them inside a loop. Then check if it has been used before before echoing: