skip to Main Content

In our website, we have textbox to ask input values from user. If user input the data Q54497899, rest of the results must be shown from database. Rightnow, I want to add checkbox on each result. I tried to add with foreach but it still doesn’t work for me. I will provide codes below which were written in the correlationwafer_result.php. Want to add checkbox beside each Q54497899

    <?php  
// ini_set("memory_limit","512M");
include("_dbconn.php");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/db_config.inc");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/standard_defines.inc");
session_start();

$productlotid = isset ($_GET['productlotid'])? $_GET['productlotid']:'';

$sql = "SELECT * FROM productdb.tbl_correlationwafer WHERE `lotid` = '$productlotid'";
    $result1 = mysqli_query($conn,$sql);
$cnt = 0;   
echo "<table id='corwafer'>";


    while ($row = mysqli_fetch_assoc($result1)) {
        echo "<tr>";
        echo "<th colspan='2'>Lot ID:</th>";
        echo "<th colspan='2'>Product:</th>";
        echo "<th colspan='4'>EWSFLOW </th>";
        echo "<th>Zone</th>";
        echo "</tr>";
        
        $field1name = $row["lotid"];
        $field2name = $row["product"];
        $field3name = $row["ewsflow"];
        $field4name = $row["zone"];

        echo '<tr> 
                  <td colspan="2">'.$field1name.'</td> 
                  <td colspan="2">'.$field2name.'</td> 
                  <td colspan="4">'.$field3name.'</td> 
                  <td >'.$field4name.'</td> 
                   
              </tr>';
              
        foreach($productlotid as $k => $v){

            if($k == $row["lotid"]){
                echo "<input type="checkbox" id="chkproductlotid" . $cnt . "" name="chkproductlotid" value="$v"><font face="arial" size="2" color="#3C5F84">". $k . "</font>";
            }
        }
        $cnt++;   
    }

echo "</table>";


flush();
mysqli_close($conn);
?>

3

Answers


  1. Try :

    $('chkproductlotid').val();
    
    Login or Signup to reply.
  2. $productlotid = isset ($_GET['productlotid'])? $_GET['productlotid']:'';
    

    Your $productlotid is more like a string not an array, does it?

    Login or Signup to reply.
  3. You should put your checkbox inside td, and I think your checkbox value should be able to take from the first While Loop, no need that Foreach..

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search