首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >计算两个字段时有问题

计算两个字段时有问题
EN

Stack Overflow用户
提问于 2013-10-03 06:58:23
回答 1查看 91关注 0票数 1

请帮忙?我有一个有记录表的数据库。两个字段,我试图计算,以获得一个特定的数字是不工作的。我对php非常陌生,希望得到任何帮助。

我的表中有两个名为"startdate"和的字段,这两个字段是在对它们进行计算后我想要回显的

“守则”:

代码语言:javascript
运行
复制
    <?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>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19152741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档