just a quicky guys when my web page loads it should display the history of jobs html table, but it doesnt until the action taken text field is submitted. does anyone know what i need to do to ensure that the html table is always displaying records if there any.
I think code just needs tweaking, cant remember what chnage i made to make it stop displaying.
<html>
<head>
</head>
<body>
<?php
require('dbconnect.php');
set_time_limit(0);
$jobId=$_GET['jobId'];
$sql = "select jobId, email, room, computers, description, date FROM requests_table
WHERE requests_table.jobId='$jobId'";
$result = mysql_query($sql);
echo "<table width=\"100%\">\n";
echo " <tr>\n";
echo " <th align=\"left\"><b>JobID</b></th>\n";
echo " <th align=\"left\"><b>Email</b></th>\n";
echo " <th align=\"left\"><b>Room</b></th>\n";
echo " <th align=\"left\"><b>Computers</b></th>\n";
echo " <th align=\"left\" ><b>Description</b></th>\n";
echo " <th align=\"left\"><b>Date&time</b></th>\n";
echo " </tr>\n";
$row = mysql_fetch_array($result);
echo '<td>'.$row['jobId'].'</td>';
echo '<td >'.$row['email'].'</td>';
echo '<td>'.$row['room'].'</td>';
echo ' <td>'.$row['computers'].'</td>'."\n";
echo ' <td>'.$row['description'].'</td>'."\n";
echo ' <td>'.$row['date'].'</td>'."\n";
echo '</tr>'."\n";
echo '</table>';
echo '<hr>';
?>
<?php
$color[0] = "FCFCFC";
$color[1] = " 34ADE5 ";
$jobId=$GET['jobId'];
$action_taken=$GET['action_taken'];
$Tech_initals=$_GET['Tech_intials'];
if($_POST["Submit1"]) {
$action_taken = addslashes($POST['action_taken']);
$Tech_initals = addslashes($POST['Tech_initals']);
$result = mysql_query("INSERT INTO tech_table (jobId, Tech_initals, action_taken, date)
VALUES ('$jobId', '$Tech_initals', '$action_taken', NOW())") or die("Unable to insert record: " . mysql_error());
$sql = "SELECT jobId, Tech_initals, action_taken, date FROM tech_table WHERE jobId='".$_GET['jobId']."'";
$result = mysql_query($sql);
}
echo "<H3><b>Job History</b></H3>";
echo "<table>\n";
echo " <tr>\n";
echo " <th><b>Tech Initals</b></th>\n";
echo " <th><b>Action taken</b></th>\n";
echo " <th><b>Date</b></th>\n";
echo " <th><b>Status of Job</b></th>\n";
echo " <th><b>Date of completion</b></th>\n";
echo " </tr>\n";
while ($row = mysql_fetch_array($result)) {
$a = ($a+1)%2;
echo '<tr bgcolor='.$color[$a] . ">\n";
//echo '<td>'.$row['jobId'].'</td>';
echo ' <td>'.$row['Tech_initals'].'</td>'."\n";
echo ' <td>'.$row['action_taken'].'</td>'."\n";
echo ' <td>'.$row['date'].'</td>'."\n";
echo ' <td>'.$row['status_of_job'].'</td>'."\n";
echo ' <td>'.$row['compdate'].'</td>'."\n";
echo '</tr>'."\n"; }
echo '</table>';
?>
</table>
<?php
if (strlen($POST['email']) > 0 ) {
$sql = "SELECT email FROM requests_table WHERE jobId='".$GET['jobId']."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$to = $row['email'];
$from = "poo@ntlworld.com";
$message = $POST['email'];
mail($to, "technical services", $message,
"From: {$from}\r\n"
."Reply-To: {$from}\r\n"
."X-Mailer: PHP/" . phpversion());
}
?>
<br>
<?php
echo '<hr>';
?>
<br>
<form name="details" method="post" action= "<? echo $SERVER['PHP_SELF'] . "?jobId=" . $jobId; ?>">
<table width="791" height="160" border="0">
<tr>
<input type="hidden" name="email">
<th width="61" scope="row">TechId</th>
<td width="245"><strong>Action taken </strong></td>
<td width="116"><strong>Status of job </strong></td>
<td width="120"> </td>
<td width="126"> </td>
<td width="97"> </td>
</tr>
<tr>
<th scope="row"><input name="Tech_initals" type="text" size="2" maxlength="2"></th>
<td><textarea name="action_taken" cols="30" rows="3"></textarea></td>
<td><input type="checkbox" name="comp" value="1"></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
if(isset($GET['comp'])){
$comp=$GET['comp'];
mysql_query("INSERT INTO tech_table (status_of_job, compdate)
VALUES ('$comp', NOW())") or die("Unable to insert record: " . mysql_error());
}
?>
<tr>
<th scope="row"> </th>
<td><strong>Email comment </strong></td>
</tr>
<tr>
<th scope="row"> </th>
<td><textarea name="email" cols="30" rows="3"></textarea></td>
</tr>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name="Submit1" value="Submit"></td>
</tr>
</table>
</form>
<hr>
</body>
</html>