Want to show checkbox for each row
P粉574695215
P粉574695215 2024-04-01 12:34:11
0
2
375

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>";

P粉574695215
P粉574695215

reply all(2)
P粉450079266

You can change the query and use MySQL's GROUP BY feature. Below is the query. Ignore any spelling errors.

$sql = "SELECT lotid, product, ewsflow, GROUP_CONCAT(zone) FROM productdb.tbl_correlationwafer WHERE lotid = ? GROUP BY lotid, product, ewsflow ORDER BY lotid";

$pq = $mysqli->prepare($sql);
$pq->bind_param('i', $productlotid);
$pq->execute();
$result = $pq->get_result();

$data = $result->fetch_all();

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."

P粉693126115

You can define an array and put lotid, product and ewsflow into it and combine them inside a loop. Then check if it has been used before before echoing:

$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 "";
    echo "Lot ID:";
    echo "$field1name";
    echo "";

    echo "";
    echo "Product:";
    echo "$field2name"; 
    echo "";

    echo "";
    echo "EWSFLOW: ";
    echo "$field3name"; 
    echo "";

    array_push($arr, $key);
}

echo "";
echo "Zone:";
echo "$field4name"; 
echo "";

}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template