当前位置:Gxlcms > PHP教程 > php中关联多张表的有关问题

php中关联多张表的有关问题

时间:2021-07-01 10:21:17 帮助过:11人阅读

php中关联多张表的问题
前一张页面:rem_list.php





session_start() ;
include_once("../include/conn.php") ;
$rem_id=$_SESSION["rem_id"] ;
$rem_name=$_SESSION["rem_name"] ;
$sql="select order_number from rem_table , order_table where rem_table.rem_id=order_table.rem_id and rem_table.rem_name='$rem_name'" ;
$mysql=mysql_query($sql) or die("Could not query.".mysql_error()) ;
$info=mysql_num_rows($mysql) ;
if($info==""){
$html_info="暂时没有订单。" ;
}
else{
$str=mysql_fetch_array($mysql) ;
$html_info="
    " ;
    do{
    $html_info.="
  • ".$str["order_number"]."
  • " ;
    }while($str=mysql_fetch_array($mysql)) ;
    $html_info.="
" ;
}
?>


欢迎 登陆







链接后:order_list.php





session_start() ;
include_once("../include/conn.php") ;
$order_number=$_GET["order_number"] ;
$rem_name=$_SESSION["rem_name"] ;
$sql="select * from order_table , deal_table where deal_table.order_id=order_table.order_id ,order_table.order_number='$order_number'" ;
//var_dump($sql) ;
$mysql=mysql_query($sql) or die("Could not query.".mysql_error()) ;
$str=mysql_fetch_array($mysql) ;
$html_info="" ;
do{
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
$html_info.="" ;
}while($str=mysql_fetch_array($mysql)) ;
$html_info.="
订单号".$str["order_number"]."
订单时间".$str["order_date"]."
订单状态".$str["deal_information"]."
" ;
?>


欢迎登陆






------解决方案--------------------
$sql="select * from order_table , deal_table where deal_table.order_id=order_table.order_id and order_table.order_number='$order_number'" ; //缺少 where 的连接条件

人气教程排行