【发布时间】:2016-03-16 23:21:26
【问题描述】:
我在传递从数据库中获取并存储在变量中的数组变量并将它们传递到会话变量以在整个站点上使用时遇到了一点问题。
代码:
$rid=$_SESSION['SESS_MEMBER_ID'] ;
$recquery = 'SELECT * FROM clinic_receptionist,clinic_table where clinic_receptionist.recep_clinic_id = clinic_table.ID AND recep_id ='.$rid;
$recresult = mysqli_query($conn,$recquery);
if(mysqli_num_rows($recresult)>0)
{
while($row = mysqli_fetch_assoc($recresult))
{
$cid = $row['clinic_id'];
$cname = $row['clinic_name'];
$name = $row['recep_full_name'];
$phone = $row['recep_mobile'];
$email = $row['recep_email'];
$address = $row['recep_address'];
$gender = explode(",",$row['recep_gender']);
$dob = $row['recep_dob'];
$doj = $row['recep_doj'];
}
}
?>
上面的代码是选择查询发生的地方。我想知道如何将$cid 和$cname 分配给不同页面中的$_SESSION 变量。任何帮助将非常感激。谢谢
代码:
<?php session_start();
include('header.php');
include('menu.php');
include('config.php');
$appquery = 'SELECT * FROM appointment_table,clinic_table where clinic_table.ID = appointment_table.clinic_id';
$appresult = mysqli_query($conn,$appquery);
if(mysqli_num_rows($appresult)>0)
{
while($row = mysqli_fetch_array($appresult))
{
$_SESSION['cid'] = $row['ID'];
$_SESSION['cname'] = $row['clinic_name'];
$ptdate = $row['date'];
$pttime = $row['time'];
$ptname = $row['pt_name'];
$ptphone = $row['pt_ph_num'];
$ptemail = $row['pt_email_id'];
}
}
?>
上面的代码是我想要接收 id 和诊所名称的地方。
【问题讨论】:
-
$_SESSION['id'] = $cid和$_SESSION['name'] = $cname -
是否有任何特定的理由来打开和关闭这么多 php 标签而不是一个?那不是更整洁吗?
-
@bIgBoY 很抱歉。