douxie7738 2018-12-20 16:29 采纳率: 0%
浏览 57

将数据附加到表中的新行

I am setting up a report that will pull information from a database. I have a new table to appear when a different user finishes their work with a client, I have this working correctly. I have used this code previously, but for some reason a new row does not append in the users table after they work with a different client. Like if I work on a project for Google for an hour, that will appear, then if I work on a project for Yahoo for an hour, only Yahoo data will appear. I want both of these to appear in a table. Any help or suggestions are greatly appreciated, thank you!

// Connecting, selecting database
$link = mysql_connect('localhost', $username, $password)
or die('Could not connect: ' . mysql_error());
//echo 'Connected successfully';
mysql_select_db($database) or die('Could not select database');

//loop thru users

$sql0 = "SELECT distinct idManager,(select email from users where id =         u.idManager) as email from users u where id in(select userid from reports where DATE(timestamp) = CURDATE())";
$zresults = mysql_query($sql0) or die('Query failed: ' . mysql_error());
$z=0;

$msg = "";

$zum=mysql_numrows($zresults);
while ($z < $zum) {

$Mid=mysql_result($zresults,$z,"idManager");
$Mmail=mysql_result($zresults,$z,"email");
  //echo $uid;

$sql = "SELECT id, timestamp, (sum((timeout+0) - (timein+0))) as TotalDurationDays,(select username from users where id = r.userid) as user, (select client from clients where id = r.clientid) as client, timein, timeout, openissues, otherissues from reports r where DATE(timestamp) = CURDATE() and userid in(select id from users where idManager = $Mid) order by (select username from users where id = r.userid) asc, (select client from clients where id = r.clientid) asc, timestamp desc";

$results = mysql_query($sql) or die('Query failed: ' . mysql_error());

$aum=mysql_numrows($results);

//mysql_close();

$a=0;
$c = true;

//$msg = "<table><tr><td>Placeholder</td></tr></table>";

$msg = $msg ."<h3>Individual User Updates</h3><table border='1' cellspacing='3' style='margin-left:1.5em;'>
            <tr>
                <th>Date</th>
                <th>User</th>
                <th>Client</th>
            </tr>";

while ($a < $aum) {

  $Id=mysql_result($results,$a,"id");
  $TotalTime=mysql_result($results,$a,"TotalDurationDays");
  $Timein=mysql_result($results,$a,"timein");
  $Timeout=mysql_result($results,$a,"timeout");
        $Date=date_format(date_create(mysql_result($results,$a,"timestamp")),'m/d/y');
  $User=mysql_result($results,$a,"user");
  $Client=mysql_result($results,$a,"client");
  $Open=mysql_result($results,$a,"openissues");
  $Other=mysql_result($results,$a,"otherissues");

$msg = $msg . "<tr".(($c = !$c)?" class='odd'":"class='even'")."><td nowrap>" . $Date . "</td><td nowrap>" . $User . "</td><td style='text-align:center;'>" . $Client . "</td></tr><tr style='background-color: #dddddd;'>
      <td></td><td style='text-align:right;font-weight:bold;'>Total Hours:</td><td class='total-hours' id='total-hours' style='text-align:center;'>" . $TotalTime ." mins. </td></tr>";

  $a++;
  }

$msg = $msg. "</table><br><hr>";
$z++;
}
//end user loop
mysql_close();
echo $msg;
?>

Expected Results

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向