Link to home
Start Free TrialLog in
Avatar of rcowen00
rcowen00Flag for United States of America

asked on

Notice: Undefined index: select

I have a list of items returned with a checkbox option.  I would like the user to select the checkbox, click the deleteFinding submit button for every checkbox.  I am currently getting "Notice: Undefined index: select"

The update query is lines 18-23  
and
the select checkbox is line 58

Any ideas what I'm doing wrong.  Thank you.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="refresh" content="text/html;charset=utf-8"/>
</head>

<body>
  
       <?php 
 
       error_reporting(E_ALL);
       if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
               
     if (isset($_POST['deleteFinding']) && count($_POST['select']) > 0){ 
                foreach ( $_POST[ 'select' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());
      }}
       ?>
              
           
       <table class="tablesorter" id="loanFindings" cellspacing="1" cellpadding="0">
       <thead>
        <tr>
         <th>Select</th>
         <th>Code</th>
         <th>Category</th>
         <th>Severity</th>
         <th>Override Severity</th>
       </tr>
      </thead>
      <tbody> 
       <tr>
       <?php
      //list loan findings 
      $loanFindings= "SELECT * FROM loanFinding JOIN finding ON finding.findingKey=loanFinding.findingKey JOIN audit ON audit.auditID=loanFinding.auditID JOIN findingCategory ON findingCategory.findingCategoryKey=finding.findingCategoryKey JOIN severity ON finding.severity=severity.severityKey WHERE audit.auditID=$auditID AND loanFinding.active = '1'";
           
      $loanFindingsList = mysql_query($loanFindings,$conn) or die(mysql_error());

      while ($loanFindingsRow = mysql_fetch_array($loanFindingsList))

      {
          $findingNumber = $loanFindingsRow['findingNumber'];
	  $loanFindingKey = $loanFindingsRow['loanFindingKey'];
	  $severity = $loanFindingsRow['severity'];
	  $customSeverity = $loanFindingsRow['customSeverity'];
	  $findingCategoryName= $loanFindingsRow['findingCategoryName']; 
          $findingVerbiage=$loanFindingsRow['findingVerbiage'];
          $redFlag=$loanFindingsRow['redFlag'];
          $verbiageCustom=$loanFindingsRow['verbiageCustom'];       
          

          echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="select[]" /></td>';
          
          echo '<td>' .$findingNumber. ' </td>';
          echo '<td>' .$findingCategoryName. ' </td>';
          echo '<td>' .$severity.'</td>';
          echo '<td>';

             $customSev= "SELECT * FROM severity";
             $customSevList = mysql_query($customSev,$conn) or die(mysql_error());
             echo "<select name=\"severityKey\">\n"; 
             echo "<option value=\"NULL\">Override Severity</option>\n";
             while($customSevListRow = mysql_fetch_array($customSevList)){
             $severitydesc = $customSevListRow['severitydesc'];
             $severity = $customSevListRow['severity'];
             $severityKey = $customSevListRow['severityKey'];
             echo "<option value=\"$severityKey\">$severity  $severitydesc</option>\n";
             }
             echo"</select>\n";
             echo' </td>'; 
           ?>
           </td>
           </tr>
           <td>
            <table class="tablesorter" id="findingVerbiage" cellspacing="0" cellpadding="0">
            <th>Standard Verbiage</th> 
            <?php
            echo '<td>' .$findingVerbiage. ' </td>';
            ?>
            </td>
            <tr>
            <th>Custom Verbiage</th>
            <td><input name="customVerbiage" style="width: 500px; height: 50px;"/></td>
            </table>
            </thead>
            </td>
            </tr>
            <?php
            } 
            ?>    
            </tbody>
            
            </table>
            </form>
</body>

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

you use $_POST['select'] without checking if it is set ,  like you do for the deleteFinding ...      if (isset($_POST['deleteFinding']) && count() > 0){
like this:
     if (isset($_POST['deleteFinding']) && isset($_POST['select'] && count($_POST['select']) > 0){ 

Open in new window

Avatar of rcowen00

ASKER

I added your suggestion, with an added ( after isset select) and the error is gone.  It is processing "something" but I get no change to the data.  I put in a  echo $deleteFinding; and NOTHING is returned.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="refresh" content="text/html;charset=utf-8"/>
</head>

<body>
  
       <?php 
 
       error_reporting(E_ALL);
       if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
        if (isset($_POST['deleteFinding']) && isset($_POST['select']) && count($_POST['select']) > 0){ 
                foreach ( $_POST[ 'select' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        echo $deleteFinding;
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());
      }}
       ?>
              
           
       <table class="tablesorter" id="loanFindings" cellspacing="1" cellpadding="0">
       <thead>
        <tr>
         <th>Select</th>
         <th>Code</th>
         <th>Category</th>
         <th>Severity</th>
         <th>Override Severity</th>
       </tr>
      </thead>
      <tbody> 
       <tr>
       <?php
      //list loan findings 
      $loanFindings= "SELECT * FROM loanFinding JOIN finding ON finding.findingKey=loanFinding.findingKey JOIN audit ON audit.auditID=loanFinding.auditID JOIN findingCategory ON findingCategory.findingCategoryKey=finding.findingCategoryKey JOIN severity ON finding.severity=severity.severityKey WHERE audit.auditID=$auditID AND loanFinding.active = '1'";
           
      $loanFindingsList = mysql_query($loanFindings,$conn) or die(mysql_error());

      while ($loanFindingsRow = mysql_fetch_array($loanFindingsList))

      {
          $findingNumber = $loanFindingsRow['findingNumber'];
	  $loanFindingKey = $loanFindingsRow['loanFindingKey'];
	  $severity = $loanFindingsRow['severity'];
	  $customSeverity = $loanFindingsRow['customSeverity'];
	  $findingCategoryName= $loanFindingsRow['findingCategoryName']; 
          $findingVerbiage=$loanFindingsRow['findingVerbiage'];
          $redFlag=$loanFindingsRow['redFlag'];
          $verbiageCustom=$loanFindingsRow['verbiageCustom'];       
          

          echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="select[]" /></td>';
          
          echo '<td>' .$findingNumber. ' </td>';
          echo '<td>' .$findingCategoryName. ' </td>';
          echo '<td>' .$severity.'</td>';
          echo '<td>';

             $customSev= "SELECT * FROM severity";
             $customSevList = mysql_query($customSev,$conn) or die(mysql_error());
             echo "<select name=\"severityKey\">\n"; 
             echo "<option value=\"NULL\">Override Severity</option>\n";
             while($customSevListRow = mysql_fetch_array($customSevList)){
             $severitydesc = $customSevListRow['severitydesc'];
             $severity = $customSevListRow['severity'];
             $severityKey = $customSevListRow['severityKey'];
             echo "<option value=\"$severityKey\">$severity  $severitydesc</option>\n";
             }
             echo"</select>\n";
             echo' </td>'; 
           ?>
           </td>
           </tr>
           <td>
            <table class="tablesorter" id="findingVerbiage" cellspacing="0" cellpadding="0">
            <th>Standard Verbiage</th> 
            <?php
            echo '<td>' .$findingVerbiage. ' </td>';
            ?>
            </td>
            <tr>
            <th>Custom Verbiage</th>
            <td><input name="customVerbiage" style="width: 500px; height: 50px;"/></td>
            </table>
            </thead>
            </td>
            </tr>
            <?php
            } 
            ?>    
            </tbody>
            
            </table>
            </form>
</body>

Open in new window

well, I presume you want to use "severityKey" instead of "select", no ?
Unless I really messed up, the select should be tied to the loanFindingKey not severityKey.
Hi rcowen00. Try to do

echo "deleteFinding = ".$deleteFinding;

I suspect you'll get nothing: if so, this means that $_POST['deleteFinfding'] is not set or $_POST['select'] is not set or count($_POST['select']) = 0

Check this with a var_dump($_POST);

Cheers
Hi. I see this code also miss a correct form declaration: it's present only the close tag </form> but not the opening tag <form> with method and action. Correct this before proceed in testing your code.

Cheers
I added the form tags and echo'd the $deleteFinding.  You are correct it is empty.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="refresh" content="text/html;charset=utf-8"/>
</head>

<body>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
       <?php 
 
       error_reporting(E_ALL);
       if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
        if (isset($_POST['deleteFinding']) && isset($_POST['select']) && count($_POST['select']) > 0){ 
                foreach ( $_POST[ 'select' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        echo $deleteFinding;
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());
      }}
       ?>
              
           
       <table class="tablesorter" id="loanFindings" cellspacing="1" cellpadding="0">
       <thead>
        <tr>
         <th>Select</th>
         <th>Code</th>
         <th>Category</th>
         <th>Severity</th>
         <th>Override Severity</th>
       </tr>
      </thead>
      <tbody> 
       <tr>
       <?php
      //list loan findings 
      $loanFindings= "SELECT * FROM loanFinding JOIN finding ON finding.findingKey=loanFinding.findingKey JOIN audit ON audit.auditID=loanFinding.auditID JOIN findingCategory ON findingCategory.findingCategoryKey=finding.findingCategoryKey JOIN severity ON finding.severity=severity.severityKey WHERE audit.auditID=$auditID AND loanFinding.active = '1'";
           
      $loanFindingsList = mysql_query($loanFindings,$conn) or die(mysql_error());

      while ($loanFindingsRow = mysql_fetch_array($loanFindingsList))

      {
          $findingNumber = $loanFindingsRow['findingNumber'];
	  $loanFindingKey = $loanFindingsRow['loanFindingKey'];
	  $severity = $loanFindingsRow['severity'];
	  $customSeverity = $loanFindingsRow['customSeverity'];
	  $findingCategoryName= $loanFindingsRow['findingCategoryName']; 
          $findingVerbiage=$loanFindingsRow['findingVerbiage'];
          $redFlag=$loanFindingsRow['redFlag'];
          $verbiageCustom=$loanFindingsRow['verbiageCustom'];       
          

          echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="select[]" /></td>';
          
          echo '<td>' .$findingNumber. ' </td>';
          echo '<td>' .$findingCategoryName. ' </td>';
          echo '<td>' .$severity.'</td>';
          echo '<td>';

             $customSev= "SELECT * FROM severity";
             $customSevList = mysql_query($customSev,$conn) or die(mysql_error());
             echo "<select name=\"severityKey\">\n"; 
             echo "<option value=\"NULL\">Override Severity</option>\n";
             while($customSevListRow = mysql_fetch_array($customSevList)){
             $severitydesc = $customSevListRow['severitydesc'];
             $severity = $customSevListRow['severity'];
             $severityKey = $customSevListRow['severityKey'];
             echo "<option value=\"$severityKey\">$severity  $severitydesc</option>\n";
             }
             echo"</select>\n";
             echo' </td>'; 
           ?>
           </td>
           </tr>
           <td>
            <table class="tablesorter" id="findingVerbiage" cellspacing="0" cellpadding="0">
            <th>Standard Verbiage</th> 
            <?php
            echo '<td>' .$findingVerbiage. ' </td>';
            ?>
            </td>
            <tr>
            <th>Custom Verbiage</th>
            <td><input name="customVerbiage" style="width: 500px; height: 50px;"/></td>
            </table>
            </thead>
            </td>
            </tr>
            <?php
            }
            echo "deleteFinding = ".$deleteFinding; 
            ?>    
            </tbody>
            
            </table>
            </form>
</body>

Open in new window

If you submit form and $deleteFinding is empty, then at least one among your conditions is false. The best thing to do now is to insert at the top of page this lines:

<?php
echo "<pre>"; //makes more readablòe the output
if (isset($_POST['submit'[)){
  var_dump($_POST);
}
?>

Then load page, submit the form and post here the results, please, so we can get some more indication about the problem.

Cheers


array(3) {
  ["auditID"]=>
  string(1) "1"
  ["code"]=>
  string(1) "2"
  ["deleteFinding"]=>
  string(15) "Delete Findings"
}
The only reference I have found for "Delete Findings" is on line 119 on the attached code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>

				
</head>
<form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
<body>


<?php 
 
       error_reporting(E_ALL);
       
   
      if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
       
         

            require_once ("include/userConnect.php");
            

            ?>

            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <input class="hidden" id="auditID" name="auditID" type="hidden" value="<?php echo $auditID; ?>" />
            <table class="tablesorter" id="loanInfo" cellspacing="1" cellpadding="0">
            <thead>
            <tr>
            <th>Loan Number</th>
            <th>Borrower</th>
            <th>Client</th>
            <th>Audit Type</th>
            <th>Auditor</th>
            <th>Tracking Date</th> 
            <th>Audit Begin Date</th> 
            <th>Audit Completed Date</th> 
            <th>Assigned Date</th>
            </tr>
            </thead>
	    <tbody>
            <?php
            //list loan information  
            $loanInfo= "SELECT * FROM loan JOIN borrower USING (loanKey)JOIN branch USING (branchKey) JOIN client ON client.clientKey=branch.clientKey JOIN audit USING (loanKey)JOIN auditType ON auditType.auditTypeKey=audit.auditTypeKey LEFT JOIN borrowerType ON borrowerType.borrowerTypeKey=borrower.type WHERE borrower.type='1' AND audit.auditID=$auditID";
        
             $loanInfoList = mysql_query($loanInfo,$conn) or die(mysql_error());
             $loanInfoResult = mysql_fetch_assoc($loanInfoList);
             $loanKey = $loanInfoResult['loanKey'];
             $auditID = $loanInfoResult['auditID'];
             $loanNumber = $loanInfoResult['loanNumber'];
             $borrowerFirstName = $loanInfoResult['firstName'];
             $borrowerLastName = $loanInfoResult['lastName'];
             $clientName = $loanInfoResult['clientName'];
             $auditTypeName= $loanInfoResult['auditTypeName']; 
             $loanKey=$loanInfoResult['loanKey'];
             $auditorID=$loanInfoResult['auditorID'];
             $auditBeginDt=$loanInfoResult['auditBeginDt'];
             $auditCompletedDt=$loanInfoResult['auditCompletedDt'];
             $dateAssigned=$loanInfoResult['dateAssigned'];
            
             echo '<td>' . $loanInfoResult['loanNumber'] . ' </td>';
             echo '<td>' . $loanInfoResult['lastName'] . $loanInfoList['firstName']. ' </td>';
             echo '<td>' . $loanInfoResult['clientName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditTypeName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditBeginDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditCompletedDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['dateAssigned'] . ' </td>';
            
             ?>
             <td><input type="submit" name="updateAudit" value="Update Audit"></td>
             </tr>
             </tbody>
             </table>
            
           
            <table class="tablesorter" id="addFinding" cellspacing="1" cellpadding="0">
            </br></br></br></br>
            <thead>
            <tbody>
            <tr>
            <th>Finding Number</th>
            </tr>
            <td>
            <select class="mainSelect" id="code" name="code">
            <?php

            $code= "SELECT * FROM finding JOIN findingCategory USING (findingCategoryKey) WHERE finding.active='1'";
            
            $codeList = mysql_query($code) or die(mysql_error());

            $codeListRow = mysql_fetch_assoc($codeList);

            while ($codeListRow = mysql_fetch_array($codeList))
                        
                {
                        
                    $findingKey = $codeListRow['findingKey'];
                    $description = $codeListRow['description'];
                    $severity = $codeListRow['severity'];

            echo "<option value=\"$findingKey\">$findingKey $findingCategoryName $description</option>\n";
                        
                }
    
                ?>
            </select>
            
            <input type="submit" name="addFinding" value="Add Finding">
            </td>
            </tr>
            </tbody>
            </table>
            <input type="submit" name="deleteFinding" value="Delete Findings">
            <input type="submit" name="updateFinding" value="Update Findings">
             

</form> 
</body> 
</html>

Open in new window

I see this time you have a select not a checkboxes group and I se that you have called it "code" not "select" like in other code snippets posted here. so you have to modify your code checking if isset($_POST['code'])... But at this point I'm a bit confused: you are posting very different codes and I don't understand what is now your problem:please, try to explain me, or post your entire page...

Cheers
What I am trying to accomplish is:
User checks the select checkbox (line163) an array
User selects the deleteFinding submit button. (line 119)
Update query sets active=0 (line 125 to 130)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>

				
</head>
<form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
<body>


<?php 
 
       error_reporting(E_ALL);
       
   
      if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
       
         

            require_once ("include/userConnect.php");
            

            ?>

            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <input class="hidden" id="auditID" name="auditID" type="hidden" value="<?php echo $auditID; ?>" />
            <table class="tablesorter" id="loanInfo" cellspacing="1" cellpadding="0">
            <thead>
            <tr>
            <th>Loan Number</th>
            <th>Borrower</th>
            <th>Client</th>
            <th>Audit Type</th>
            <th>Auditor</th>
            <th>Tracking Date</th> 
            <th>Audit Begin Date</th> 
            <th>Audit Completed Date</th> 
            <th>Assigned Date</th>
            </tr>
            </thead>
	    <tbody>
            <?php
            //list loan information  
            $loanInfo= "SELECT * FROM loan JOIN borrower USING (loanKey)JOIN branch USING (branchKey) JOIN client ON client.clientKey=branch.clientKey JOIN audit USING (loanKey)JOIN auditType ON auditType.auditTypeKey=audit.auditTypeKey LEFT JOIN borrowerType ON borrowerType.borrowerTypeKey=borrower.type WHERE borrower.type='1' AND audit.auditID=$auditID";
        
             $loanInfoList = mysql_query($loanInfo,$conn) or die(mysql_error());
             $loanInfoResult = mysql_fetch_assoc($loanInfoList);
             $loanKey = $loanInfoResult['loanKey'];
             $auditID = $loanInfoResult['auditID'];
             $loanNumber = $loanInfoResult['loanNumber'];
             $borrowerFirstName = $loanInfoResult['firstName'];
             $borrowerLastName = $loanInfoResult['lastName'];
             $clientName = $loanInfoResult['clientName'];
             $auditTypeName= $loanInfoResult['auditTypeName']; 
             $loanKey=$loanInfoResult['loanKey'];
             $auditorID=$loanInfoResult['auditorID'];
             $auditBeginDt=$loanInfoResult['auditBeginDt'];
             $auditCompletedDt=$loanInfoResult['auditCompletedDt'];
             $dateAssigned=$loanInfoResult['dateAssigned'];
            
             echo '<td>' . $loanInfoResult['loanNumber'] . ' </td>';
             echo '<td>' . $loanInfoResult['lastName'] . $loanInfoList['firstName']. ' </td>';
             echo '<td>' . $loanInfoResult['clientName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditTypeName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditBeginDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditCompletedDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['dateAssigned'] . ' </td>';
            
             ?>
             <td><input type="submit" name="updateAudit" value="Update Audit"></td>
             </tr>
             </tbody>
             </table>
            
           
            <table class="tablesorter" id="addFinding" cellspacing="1" cellpadding="0">
            </br></br></br></br>
            <thead>
            <tbody>
            <tr>
            <th>Finding Number</th>
            </tr>
            <td>
            <select class="mainSelect" id="code" name="code">
            <?php

            $code= "SELECT * FROM finding JOIN findingCategory USING (findingCategoryKey) WHERE finding.active='1'";
            
            $codeList = mysql_query($code) or die(mysql_error());

            $codeListRow = mysql_fetch_assoc($codeList);

            while ($codeListRow = mysql_fetch_array($codeList))
                        
                {
                        
                    $findingKey = $codeListRow['findingKey'];
                    $description = $codeListRow['description'];
                    $severity = $codeListRow['severity'];

            echo "<option value=\"$findingKey\">$findingKey $findingCategoryName $description</option>\n";
                        
                }
    
                ?>
            </select>
            
            <input type="submit" name="addFinding" value="Add Finding">
            </td>
            </tr>
            </tbody>
            </table>
            <input type="submit" name="deleteFinding" value="Delete Findings">
            <input type="submit" name="updateFinding" value="Update Findings">
       <?php 
 
       
         
		if (isset($_POST['deleteFinding']) && count($_POST['select']) > 0){ 
                foreach ( $_POST[ 'select' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());
      }}
       ?>
     <table class="tablesorter" id="loanFindings" cellspacing="1" cellpadding="0">
       <thead>
        <tr>
         <th>Select</th>
         <th>Code</th>
         <th>Category</th>
         <th>Severity</th>
         <th>Override Severity</th>
       </tr>
      </thead>
      <tbody> 
       <tr>
       <?php
      //list loan findings 
      $loanFindings= "SELECT * FROM loanFinding JOIN finding ON finding.findingKey=loanFinding.findingKey JOIN audit ON audit.auditID=loanFinding.auditID JOIN findingCategory ON findingCategory.findingCategoryKey=finding.findingCategoryKey JOIN severity ON finding.severity=severity.severityKey WHERE audit.auditID=$auditID AND loanFinding.active = '1'";
           
      $loanFindingsList = mysql_query($loanFindings,$conn) or die(mysql_error());

      while ($loanFindingsRow = mysql_fetch_array($loanFindingsList))

      {
          $findingNumber = $loanFindingsRow['findingNumber'];
          $loanFindingKey = $loanFindingsRow['loanFindingKey'];
          $severity = $loanFindingsRow['severity'];
          $customSeverity = $loanFindingsRow['customSeverity'];
          $findingCategoryName= $loanFindingsRow['findingCategoryName']; 
          $findingVerbiage=$loanFindingsRow['findingVerbiage'];
          $redFlag=$loanFindingsRow['redFlag'];
          $verbiageCustom=$loanFindingsRow['verbiageCustom'];       
          

          echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="select[]" /></td>';
          
          echo '<td>' .$findingNumber. ' </td>';
          echo '<td>' .$findingCategoryName. ' </td>';
          echo '<td>' .$severity.'</td>';
          echo '<td>';

             $customSev= "SELECT * FROM severity";
             $customSevList = mysql_query($customSev,$conn) or die(mysql_error());
             echo "<select name=\"severityKey\">\n"; 
             echo "<option value=\"NULL\">Override Severity</option>\n";
             while($customSevListRow = mysql_fetch_array($customSevList)){
             $severitydesc = $customSevListRow['severitydesc'];
             $severity = $customSevListRow['severity'];
             $severityKey = $customSevListRow['severityKey'];
             echo "<option value=\"$severityKey\">$severity  $severitydesc</option>\n";
             }
             echo"</select>\n";
             echo' </td>'; 
           ?>
           </td>
           </tr>
           <td>
            <table class="tablesorter" id="findingVerbiage" cellspacing="0" cellpadding="0">
            <th>Standard Verbiage</th> 
            <?php
            echo '<td>' .$findingVerbiage. ' </td>';
            ?>
            </td>
            <tr>
            <th>Custom Verbiage</th>
            <td><input name="customVerbiage" style="width: 500px; height: 50px;"/></td>
            </table>
            </thead>
            </td>
            </tr>
            <?php
            } 
            ?>    
            </tbody>
            
            </table>         

</form> 
</body> 
</html>

Open in new window

I'm not sure how it resolved the issue but, I changed the name of the check box to echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="toselect[]" /></td>'; and if (isset($_POST['deleteFinding']) && count($_POST['toselect']) > 0){
                foreach ( $_POST[ 'toselect' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>

				
</head>
<form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
<body>


<?php 
 
       error_reporting(E_ALL);
       
   
      if (array_key_exists('auditID', $_POST)) {
          $auditID = $_POST['auditID'];
          } else {
          $auditID = $_GET['auditID'];
          }
       
         

            require_once ("include/userConnect.php");
            

            ?>

            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <input class="hidden" id="auditID" name="auditID" type="hidden" value="<?php echo $auditID; ?>" />
            <table class="tablesorter" id="loanInfo" cellspacing="1" cellpadding="0">
            <thead>
            <tr>
            <th>Loan Number</th>
            <th>Borrower</th>
            <th>Client</th>
            <th>Audit Type</th>
            <th>Auditor</th>
            <th>Tracking Date</th> 
            <th>Audit Begin Date</th> 
            <th>Audit Completed Date</th> 
            <th>Assigned Date</th>
            </tr>
            </thead>
	    <tbody>
            <?php
            //list loan information  
            $loanInfo= "SELECT * FROM loan JOIN borrower USING (loanKey)JOIN branch USING (branchKey) JOIN client ON client.clientKey=branch.clientKey JOIN audit USING (loanKey)JOIN auditType ON auditType.auditTypeKey=audit.auditTypeKey LEFT JOIN borrowerType ON borrowerType.borrowerTypeKey=borrower.type WHERE borrower.type='1' AND audit.auditID=$auditID";
        
             $loanInfoList = mysql_query($loanInfo,$conn) or die(mysql_error());
             $loanInfoResult = mysql_fetch_assoc($loanInfoList);
             $loanKey = $loanInfoResult['loanKey'];
             $auditID = $loanInfoResult['auditID'];
             $loanNumber = $loanInfoResult['loanNumber'];
             $borrowerFirstName = $loanInfoResult['firstName'];
             $borrowerLastName = $loanInfoResult['lastName'];
             $clientName = $loanInfoResult['clientName'];
             $auditTypeName= $loanInfoResult['auditTypeName']; 
             $loanKey=$loanInfoResult['loanKey'];
             $auditorID=$loanInfoResult['auditorID'];
             $auditBeginDt=$loanInfoResult['auditBeginDt'];
             $auditCompletedDt=$loanInfoResult['auditCompletedDt'];
             $dateAssigned=$loanInfoResult['dateAssigned'];
            
             echo '<td>' . $loanInfoResult['loanNumber'] . ' </td>';
             echo '<td>' . $loanInfoResult['lastName'] . $loanInfoList['firstName']. ' </td>';
             echo '<td>' . $loanInfoResult['clientName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditTypeName'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditorID'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditBeginDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['auditCompletedDt'] . ' </td>';
             echo '<td>' . $loanInfoResult['dateAssigned'] . ' </td>';
            
             ?>
             <td><input type="submit" name="updateAudit" value="Update Audit"></td>
             </tr>
             </tbody>
             </table>
            
           
            <table class="tablesorter" id="addFinding" cellspacing="1" cellpadding="0">
            </br></br></br></br>
            <thead>
            <tbody>
            <tr>
            <th>Finding Number</th>
            </tr>
            <td>
            <select class="mainSelect" id="code" name="code">
            <?php

            $code= "SELECT * FROM finding JOIN findingCategory USING (findingCategoryKey) WHERE finding.active='1'";
            
            $codeList = mysql_query($code) or die(mysql_error());

            $codeListRow = mysql_fetch_assoc($codeList);

            while ($codeListRow = mysql_fetch_array($codeList))
                        
                {
                        
                    $findingKey = $codeListRow['findingKey'];
                    $description = $codeListRow['description'];
                    $severity = $codeListRow['severity'];

            echo "<option value=\"$findingKey\">$findingKey $findingCategoryName $description</option>\n";
                        
                }
    
                ?>
            </select>
            
            <input type="submit" name="addFinding" value="Add Finding">
            </td>
            </tr>
            </tbody>
            </table>
            <input type="submit" name="deleteFinding" value="Delete Findings">
            <input type="submit" name="updateFinding" value="Update Findings">
       <?php 
 
       
         
		if (isset($_POST['deleteFinding']) && count($_POST['toselect']) > 0){ 
                foreach ( $_POST[ 'toselect' ] as $deleteID) {
        // Set active status on findings to 0
        $deleteFinding="UPDATE loanFinding SET active='0' WHERE loanFindingKey=$deleteID";
        $deleteFindingRow=mysql_query($deleteFinding)or die(mysql_error());
      }}
       ?>
     <table class="tablesorter" id="loanFindings" cellspacing="1" cellpadding="0">
       <thead>
        <tr>
         <th>Select</th>
         <th>Code</th>
         <th>Category</th>
         <th>Severity</th>
         <th>Override Severity</th>
       </tr>
      </thead>
      <tbody> 
       <tr>
       <?php
      //list loan findings 
      $loanFindings= "SELECT * FROM loanFinding JOIN finding ON finding.findingKey=loanFinding.findingKey JOIN audit ON audit.auditID=loanFinding.auditID JOIN findingCategory ON findingCategory.findingCategoryKey=finding.findingCategoryKey JOIN severity ON finding.severity=severity.severityKey WHERE audit.auditID=$auditID AND loanFinding.active = '1'";
           
      $loanFindingsList = mysql_query($loanFindings,$conn) or die(mysql_error());

      while ($loanFindingsRow = mysql_fetch_array($loanFindingsList))

      {
          $findingNumber = $loanFindingsRow['findingNumber'];
          $loanFindingKey = $loanFindingsRow['loanFindingKey'];
          $severity = $loanFindingsRow['severity'];
          $customSeverity = $loanFindingsRow['customSeverity'];
          $findingCategoryName= $loanFindingsRow['findingCategoryName']; 
          $findingVerbiage=$loanFindingsRow['findingVerbiage'];
          $redFlag=$loanFindingsRow['redFlag'];
          $verbiageCustom=$loanFindingsRow['verbiageCustom'];       
          

  echo '<td><input type="checkbox"  value="' . $loanFindingsRow['loanFindingKey'] . ' " name="toselect[]" /></td>';
          echo '<td>' .$findingNumber. ' </td>';
          echo '<td>' .$findingCategoryName. ' </td>';
          echo '<td>' .$severity.'</td>';
          echo '<td>';

             $customSev= "SELECT * FROM severity";
             $customSevList = mysql_query($customSev,$conn) or die(mysql_error());
             echo "<select name=\"severityKey\">\n"; 
             echo "<option value=\"NULL\">Override Severity</option>\n";
             while($customSevListRow = mysql_fetch_array($customSevList)){
             $severitydesc = $customSevListRow['severitydesc'];
             $severity = $customSevListRow['severity'];
             $severityKey = $customSevListRow['severityKey'];
             echo "<option value=\"$severityKey\">$severity  $severitydesc</option>\n";
             }
             echo"</select>\n";
             echo' </td>'; 
           ?>
           </td>
           </tr>
           <td>
            <table class="tablesorter" id="findingVerbiage" cellspacing="0" cellpadding="0">
            <th>Standard Verbiage</th> 
            <?php
            echo '<td>' .$findingVerbiage. ' </td>';
            ?>
            </td>
            <tr>
            <th>Custom Verbiage</th>
            <td><input name="customVerbiage" style="width: 500px; height: 50px;"/></td>
            </table>
            </thead>
            </td>
            </tr>
            <?php
            } 
            ?>    
            </tbody>
            
            </table>         

</form> 
</body> 
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, rcowen00. I wish to tell that you must select some checkbox to view them in $_POST array: if you leave them unchecked, they simplywill not appear in $_POST array. I repeat: only cheked values will appear in $_POST array. So, to test your code you must select at least one checkbox.

You can download Netbeans here: http://netbeans.org/ It's free and has an optimal syntax checking system that highlight all errors in your code. Sometimes it highlight a closed tag as error because it doesn't find opened tag if you opened it within php code. So if you write

<?php
echo "<tr>";
?>
</tr>

the closing tag will be red highlighted as error. Then, it's better to write html code always in html and not echoing it within php tags to take advantage by this feature. Anyway, Netbeans will help you to write a better code.

Cheers
MarqusG,

Thanks, NetBean is great.  I'm using it to clean up my code.
I'm glad you like netbeans and thanks for points. I'm glad you solved your problem also. What about your other question: https://www.experts-exchange.com/questions/26550347/Foreach-Invalid-Argument.html?anchorAnswerId=33928102#a33928102. That seems to be strictly related to this one...

Cheers
Yes I think it is related but I haven't had the opportunity to get back to that one yet.  It is next on the list.