Jump to content

Recommended Posts

I am trying to write a callback table where I want to exclude certain records. Namely records that have been hired. My current work around is that I display "YES" in the hired field.

 

Here is the entire code:

 

<?php
require_once("all_includes.php");
session_start();
check_valid_user();
$conn = new db_conn();
@include 'header.php';

// get posted values (from: endorsement search)
$e = isset($_POST['e']) ? $_POST['e'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
?>

<body>
<table border="2">
<form name="search_form" method="post" action="">
<tr>
	<td align=right>Name Search:</td>
	<td><input type="text" name="name" <?php if ($name != "") echo "value=".$name ?>></td>
	<td><input type="submit" value="search" name="search_name"></td>
</tr>
<tr>
	<td>Endorsement Search:</td>
	<td> 
		<select name="e">
			<?php codes($e); ?>
		</select>
	</td>
	<td><input type="submit" value="search" name="submit_e"></td>
</tr>
</form>
</table>
<p>
<table border="1" width="100%">
  <tr>
    	<td height="24"><div align="center">Name</div></td>
    	<td height="24"><div align="center">Application</div></td>
    	<td height="24"><div align="center">Comments</div></td>
        <td height="24" colspan="7"><div align="center">Endorsements</div></td>
<td height="24"><div align="center">Application Date</div></td>
    	<td height="24"><div align="center">Expiration Date</div></td>
        <td height="24"><div align="center">Offered</div></td>
        <td height="24"><div align="center">Hired</div></td>
  </tr>
  <?php

// 11.12.07
$query  = "SELECT lastName, firstName, dateApplied, expiration, ";
$query .= "end1, end2, end3, end4, end5, end6, end7, ";
$query .= "generalInfo.id, offered, hired from ";
$query .= "activation ";

if ($e!='Show' && $e != ''){
$query .= "join certificationInfo on end1=".$e;
$query .= " or end2=".$e." or end3=".$e." or end4=".$e;
$query .= " or end5=".$e." or end6=".$e." or end7=".$e." ";
}
else $query .= ",certificationInfo ";

$query .= "join generalInfo on firstName like '%" . $name . "%' ";
$query .= "or lastName like '%" . $name . "%' ";

$query .= "where generalInfo.id = certificationInfo.id ";
$query .= "and generalInfo.id = activation.id ";
$query .= "and activation.active = 1 ";
$query .= "order by lastName ";

//echo "query: ".$query."<br>";

$res = $conn->query ($query) or die ('Could not execute query: '.mysql_error());


for($i=0; $row = mysql_fetch_assoc($res); $i++){

// format "offered" and "hired" values displayed
if ($row['offered'] == 0) $offered = "-";
else $offered = "YES";

if ($row['hired'] == 0) $hired = "-";
else $hired = "YES";

// format endorsement values displayed
for ($i=1;$i<8; $i++){
	$end = "end" . $i . "";
	$end_arr[$i] = $row[$end];
	if ($end_arr[$i] == 0) $end_arr[$i] = '-';
}

echo   "<tr>
	<td>".$row['lastName'].", ".$row['firstName']."</a></td>
	<td><a href = 'printable.php?id=".$row['id']."'>View</td>
	<td><a href = 'comments.php?id=".$row['id']."'>View</td>
	<td>".$end_arr[1]."</td>
	<td>".$end_arr[2]."</td>
	<td>".$end_arr[3]."</td>
	<td>".$end_arr[4]."</td>
	<td>".$end_arr[5]."</td>
	<td>".$end_arr[6]."</td>
	<td>".$end_arr[7]."</td>
	<td>".$row['dateApplied']."</td>
	<td>".$row['expiration']."</td>
	<td>".$offered."</td>
	<td>".$hired."</td>
	</tr>";
}

?>
</table>
</body>
</html>

<?php
function codes($ca){
        $file1 = "MDE_codes.txt";

        $lines = file($file1);
        foreach ($lines as $line){
                $line = trim($line);
                $items = split("\t",$line);
                //$line = trim($line);
                $s  = "<option value=".$items[0];
                if ($ca == $items[0]){
		$s .= " selected";
	}
                $s .= ">".$line."</option>\n";
                echo $s;
                //fwrite($fh,$s);
        }

        //fclose($fh);
}
?>

 

Here is the code that is dealing with the hired records:

	if ($row['hired'] == 0) $hired = "-";
else $hired = "YES";

 

I want to exclude everything that is currently displaying "YES"

 

Any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/146521-solved-excluding-certain-records/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.