我试图从数据库中的两个不同的表中提取数据,但我仍然遇到错误。当我运行代码时它什么都没显示
这是我的代码:
<?php
$st="";
$sc="";
if (isset($_POST['submit']) && $_POST['submit'] == "submit"){
$st=$_POST['s-t'];
$sc= "WHERE nums like \"%$st%\" or d_n like \"%st%\" ";
}
if (isset ($_GET['look']) && $_GET ['look'] != "") {
$st=$_GET['look'];
$sc = "WHERE nums like \"%$st%\" or d_n like \"%st%\" ";
}
$db = mysql_db_connect();
$rpp = 50;
if (isset($_GET['page'])){
$pn = $_GET['page'];
$begin = ($rpp*$pn)-$rpp;
$finish=($rpp*$pn);
$finish=50;
}
else {
$pn =1;
$begin = 0;
$finish =$rpp;
}
$returns = mysql_query ("SELECT * FROM extenz $sc", $db);
$numer_rows = mysql_num_rows($returns);
$number_pages = ((int) ($numer_rows/$rpp)) +1;
if (($number_rows % rpp) ==0){
$number_pages=$number_pages -1;
}
$returns = mysql_query("SELECT nums, name , p_m FROM extenz, P_exten left join p_exten on extenz $sc order by nums & P_m LIMIT $begin, $finish", $db);
?>
答案 0 :(得分:0)
我回答了我的问题
错误发生在以下代码行
中$returns = mysql_query("SELECT nums, name , p_m FROM extenz, P_exten left join p_exten on extenz $sc order by nums & P_m LIMIT $begin, $finish", $db);
并且更正是
$returns = mysql_query("SELECT extenz.nums, extenz.name,p_exten.P_M FROM extenz LEFT JOIN ON p_exten.extenz=extenz.nums $sc ORDER BY nums LIMIT $begin, $finish",$db);