Php 我想合并到sql数据库的函数?
模型页Php 我想合并到sql数据库的函数?,php,mysql,Php,Mysql,模型页 function msghead1($a) { $r=mysql_query("SELECT * FROM messagedetails JOIN admission_msg ON messagedetails.s_no=admission_msg.msg_id and adm_no='$a' ORDER BY s_no desc;"); return $r; } function msghead
function msghead1($a)
{
$r=mysql_query("SELECT * FROM messagedetails JOIN admission_msg ON messagedetails.s_no=admission_msg.msg_id and adm_no='$a' ORDER BY s_no desc;");
return $r;
}
function msghead2($a)
{
$r=mysql_query("SELECT * FROM messagedetails where status='$a' or status='Al' ORDER BY s_no desc;");
return $r;
}
主页
这是我的模型在同一张表上运行的两个函数,但问题是我必须使用这两个函数的输出以单顺序打印。。。虽然它们是有序的,但当第一个顺序结束时,第二个顺序开始。意味着他们使用的顺序不同。。如果有任何疑问,你可以问试试这个
$bid=0;
include 'model.php';
$db=new database;
$r=$db->msghead1($admno,$sclass);
while($row= mysql_fetch_array($r))
{
$id=$row[0];
$title=$row[1];
$msg=$row[2];
$date=$row[3];
$sender=$row[4];
$tit_status=$row["title_status"];
$bid=$bid+1;
$pid=$pid+1;
include'msg.php';
}
$r1=$db->msghead2($sclass);
$bid=0; // here i change
while($row= mysql_fetch_array($r1))
{
$id=$row[0];
$title=$row[1];
$msg=$row[2];
$date=$row[3];
$sender=$row[4];
$tit_status=$row["title_status"];
$bid=$bid+1;
$pid=$pid+1;
include'msg.php';
}
?>
您的PHP脚本应该做什么?它从数据库中获取数据并根据日期打印,但我获取了两种类型的数据,所以我希望以单一顺序合并这些数据
$bid=0;
include 'model.php';
$db=new database;
$r=$db->msghead1($admno,$sclass);
while($row= mysql_fetch_array($r))
{
$id=$row[0];
$title=$row[1];
$msg=$row[2];
$date=$row[3];
$sender=$row[4];
$tit_status=$row["title_status"];
$bid=$bid+1;
$pid=$pid+1;
include'msg.php';
}
$r1=$db->msghead2($sclass);
$bid=0; // here i change
while($row= mysql_fetch_array($r1))
{
$id=$row[0];
$title=$row[1];
$msg=$row[2];
$date=$row[3];
$sender=$row[4];
$tit_status=$row["title_status"];
$bid=$bid+1;
$pid=$pid+1;
include'msg.php';
}
?>
<div class="item">
<button style="width:90%;height:40px; margin-left:5%;" onclick="MessageDetailsById(<?php echo $id;?>)">
<?php if($tit_status=="1") { ?>
<i class="fa fa-plus-circle" aria-hidden="true" style="width:20px;float:left;"></i> <i class="fa fa-envelope-open-o" aria-hidden="true"></i> <span id="active" class="sidebar-title" ><?php echo $title; ?></span> <?php echo $date;?>
<?php }
else
{ ?>
<i class="fa fa-plus-circle" aria-hidden="true" style="width:20px;float:left;"></i> <i class="fa fa-envelope-o" aria-hidden="true"></i> <span id="active<?php echo $tit_status;?>" class="sidebar-title" style="color:red;"><?php echo $title; ?></span> <?php echo $date;?>
<?php } ?>
</a></button>
<p style="display:none;margin-left:5%;" id="<?php echo $id; ?>"> <?php echo $msg; ?> </p>
</div>