Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP MySql按日期逐个打印数据表排序_Php_Mysql - Fatal编程技术网

PHP MySql按日期逐个打印数据表排序

PHP MySql按日期逐个打印数据表排序,php,mysql,Php,Mysql,我有三张桌子 表1:tbl_营销,表2:tbl_电话,表3:tbl_电子邮件 表2和表3包含表1的id 表2: 表3: 现在我想为用户打印输出表 输出将是两个表,一个包含表2的数据,另一个包含表3的数据,其中两个表包含表1的相同id,如果您在上面进行检查,则表1的id将存储在表2和表3的db_mid中 这不是我的问题,我的问题是我想先打印一张表,然后再打印另一张表 表2和表3可以包含具有相同id的主行 表1和我想展示它们 如果表2中的db_phdate大于表3中的db_edate,则将首先打印表

我有三张桌子

表1:tbl_营销,表2:tbl_电话,表3:tbl_电子邮件

表2和表3包含表1的id

表2:

表3:

现在我想为用户打印输出表

输出将是两个表,一个包含表2的数据,另一个包含表3的数据,其中两个表包含表1的相同id,如果您在上面进行检查,则表1的id将存储在表2和表3的db_mid中

这不是我的问题,我的问题是我想先打印一张表,然后再打印另一张表

表2和表3可以包含具有相同id的主行 表1和我想展示它们

如果表2中的db_phdate大于表3中的db_edate,则将首先打印表2,然后再打印表3

如果表3中的db_edate大于表2中的db_phdate,则将首先打印表3,然后再打印表2

如何在从mysql数据库获取数据的while循环中实现这一点

PHP代码

从数据库中获取数据

$query=mysqli_query($conn,"Select * from tbl_phonecall,tbl_email 
    where tbl_phonecall.db_mid='$getid' or tbl_email.db_mid='$getid'")or die(mysqli_error($conn));
    while($row=mysqli_fetch_array($query)){
    $phid=$row['db_id'];
    $phdate=$row['db_phdate'];
    $phsubject=$row['db_subject'];
    $phdesc=$row['db_desc'];
    $phdue=$row['db_due'];
    $phnextdate=$row['db_nextdate'];
    $phduration=$row['db_duration'];
    $phclient=$row['db_client'];
    $phstatus=$row['db_phstatus'];
    $phnote=$row['db_note'];
    $phuser=$row['db_phuser'];
    $phisdone=$row['db_isdone'];
    $phlogs=$row['db_logs'];
    $phcrf=$row['db_crf'];
    $phphone=$row['db_phone'];
    $phcallto=$row['db_callto'];
    /***************************/
    $eid=$row['db_eid'];
    $edate=$row['db_edate'];
    $esubject=$row['db_esubject'];
    $edesc=$row['db_edesc'];
    $edos=$row['db_dos'];
    $edor=$row['db_dor'];
    $eclient=$row['db_eclient'];
    $estatus=$row['db_estatus'];
    $enote=str_replace('\r\n','<br>',$row['db_note']);
    $euser=$row['db_euser'];
    $elogs=$row['db_logs'];
    $eerf=$row['db_erf'];
    $eemail=$row['db_email'];
    $eemailto=$row['db_emailto'];
}
打印表2的html标题

Html标题表3


我不明白这是怎么回事question@Strawberry我想打印这个表,但是当db_phdate大于db_edate时,我会在表3的内容之前打印表2的内容,如果db_edate大于db_phdate,我会在表2之前打印表3的内容,我想这就是ORDER BY子句的作用。@草莓,这是两个表怎么可以按ORDER BY从两张桌子上比较?!示例PLZEX与使用一个表的方式完全相同。
 echo'<div class="table-responsive">';
    echo"<table class='ol-md-12 table-bordered table-striped table-condensed cf table-bordered' >";
    echo"<thead class='cf'>";
    echo"<tr>";
echo"
<th >#</th>
<th >Date</th>
<th >Customer</th>
<th >Subject</th>
<th >Desc</th>
<th >Staff</th>
<th >Due</th>
<th >Next Date</th>
<th >Duration</th>
<th >Status</th>
<th >Client</th>
<th >call received from</th>
<th >Callto</th>
<th >Phone</th>
<th >IsDone</th>
<th >Logs</th>
<th >Note</th>
<th >RM</th>
<th >Edit</th>";
<th >#</th>
<th >Date</th>
<th >Subject</th>
<th >Staff</th>
<th >Desc</th>
<th >Client</th>
<th>Email Receive From</th>
<th >Email To</th>
<th >Email</th>
<th >Date Of Sending</th>
<th >Date Of Receiving</th>
<th >Status</th>
<th >Logs</th>
<th>Note</th>
<th >RM</th>
<th >Edit</th>";