hi guys,
just a little problem i have a form with a text field and a check box and one submit button. when the text field gets submitted the time and date are inserted in to the date column. however when the check box is checked a time and date should also be inserted in to the compdate column but it doesnt on the table that i display on the webpage however it does in the database. in the tabel that is displayed the date gets put in to the date column but it should go in to the compdate column.
i know thsi is happening becuase when submit is pressed the first insert is inot the date column and not the compdate.
but can anyone help me fix it
here is my code
<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 mysql_error() ;
echo "<table width=\"100%\">\n";
//echo "<table>\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";
while ($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>';
?>
<br>
<?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 ";
$sql = "SELECT jobId, Tech_initals, action_taken, date FROM tech_table WHERE jobId='".$_GET['jobId']."'";
$result = mysql_query($sql);
echo "<H1><b>Job History</b></H1>";
echo "<table>\n";
echo " <tr>\n";
echo " <th><b>JobID</b></th>\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)) {
//print_r($result) ;
// echo mysql_error() ;
$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>
<br>
<?php
echo '<hr>';
?>
<br>
<p> </p>
<form name="details" method="post" action= "<? echo $_SERVER['PHP_SELF'] . "?jobId=" . $jobId; ?>">
<table width="791" height="160" border="0">
<tr>
<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'])){
//if(isset($REQUEST['comp']?1:0😉) {
$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><input type="submit" name="Submit1" value="Submit"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>