请协助?我有一个带有记录表的数据库。我试图计算以获得某个数字的两个字段不起作用。我对 php 真的很陌生,如果有任何帮助,我将不胜感激。
我的表有 2 个名为“startdate”和“terminationdate”的字段,这是我在为它们完成计算后想要回显的两个字段
编码:
<?php
include 'core/init.php';
protect_page();
include 'includes/overall/header.php';
error_reporting(1);
?>
<div class="article">
<h2>
<br>
SEARCH A REFERENCE
<br>
</h2>
</center>
<body>
<div id="formsearch">
<br>
<form method="post" action="" name="form1" id="form1" >
Enter the ID Number
<br><br>
<b>Search Record </b> <input type="text" name="term" /><br />
<br>
<input type="submit" name="submit" value="Search" class="btn" />
</form>
</div>
<h3> <center> Search Result (s) </h3>
<?php
if ($_REQUEST['submit']) {
$term = $_POST['term'];
$row ['employerid'] == $user_data ['user_id'];
$XX = "<br><br><div class='messagebox'><h2> <center> Oops! </h2> <p>We were only to retrieve a partial record on <strong>$term</strong> you have entered. Please make use of our contact form if you would like us to get you your reference. Be sure to enter the three required fields. <a href='Mailforms/refrequest.php' class='lightbox'>Click Here!</a> or to validate the id <a href='idverification.php'> Click here</a></p>
<br />
</div>";
$sql = mysql_query("SELECT idnumber,
firstname,
lastname,
companyname,
jobtitle,
dismissal,
floor(terminationdate - startdate) + ' days ' +
MOD(FLOOR ((terminationdate - startdate) * 24), 24) + 'hours' +
MOD (FLOOR ((terminationdate - startdate) * 24 * 60), 60) + ' minutes ' 'time_diff'
FROM ref_employees
WHERE idnumber= '$term'")
or die('Error in query : $sql. ' .mysql_error());
if (mysql_num_rows($sql) > 0 ) {
while ($row = mysql_fetch_array($sql)){
if ($row ['employed'] == '1') {
echo '<h4>Currently Employed By : '.$row['companyname'];
echo '</h4> ';
echo '<a href="#">Any doubts? Enquire about this candidate</a> ';
}
if ($row ['employed'] == '0') {
echo ' <h4>Some Available Options For:</h4>';
include 'includes/admenu.php';
echo '<h4>Not Currently employed '.$row['companyname'];
echo '</h4> ';
}
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID Number</th> <th>First Name</th> <th>Last Name</th><th>company</th> <th>Job Title</th> <th>Period</th><th>Reason for dismissal</th><th></th><th></th></tr>";
echo "<tr>";
echo '<td>' . $row['idnumber'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td>' . $row['companyname'] . '</td>';
echo '<td>' . $row['jobtitle'] . '</td>';
echo '<td>' .($row['startdate'] + $row['terminationdate']).'</td>';
echo '<td>' . $row['dismissal'] . '</td>';
echo '<td><a href="editemp.php?idnumber=' . $row['idnumber'] . '">Achievements</a></td>';
echo '<td><a href="delete.php?idnumber=' . $row['idnumber'] . '">training</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
}
}
else
{
print ("$XX");
}
mysql_free_result($sql);
mysql_close($connection);
?>
<div>
</div>
<?php
include 'includes/overall/footer.php'; ?></div>