当前位置 : 主页 > 网络编程 > PHP >

有意思的代码(求解)

来源:互联网 收集:自由互联 发布时间:2021-06-30
case 'comment': $cla=$_POST[cla]; switch ($cla) { case '1': $table_ = 'x_designer_dp'; break; case '2': $table_ = 'x_merchant_dp'; break; case '3': $table_ = 'x_product_dp'; break; case '4': $table_ = 'x_project_dp'; break; case '5': $table
 
case 'comment':    
    $cla=$_POST[cla];
    switch ($cla) {
        case '1':
            $table_ = 'x_designer_dp';
            break;
        case '2':
            $table_ = 'x_merchant_dp';
            break;
        case '3':
            $table_ = 'x_product_dp';
            break;
        case '4':
            $table_ = 'x_project_dp';
            break;
        case '5':
            $table_ = 'x_supervisor_dp';
            break;
        case '6':
            $table_ = 'x_troops_dp';
            break;                                                      
        default:
            # code...
            break;
    }
    $fen=$_POST[fen];
    switch ($fen) {
        case '1':
            $sql = "";
            break;
        case '2':
            $sql = " and p.score=5";
            break;
        case '3':
            $sql = " and (p.score>=2 and p.score<=4)";
            break;
        case '4':
            $sql = " and p.score=1";
            break;                              
        default:
            # code...
            break;
    }
    $bid=$_POST[bid];
  
    $pageIndex=($_POST[pageIndex]-1)*$_POST[displayNumber];
    $displayNumber=$_POST[displayNumber];   
    $result_num = mysql_query("select p.id from ".$table_." p where p.bid='$bid'".$sql);
    $total = mysql_num_rows($result_num);
    $total_page=ceil($total/$displayNumber);    
    $arr=array();       
    $query=mysql_query("select p.*,u.name from ".$table_." p 
    left join x_user u on p.uid=u.uid 
     where p.bid='$bid' ".$sql." order by p.id desc limit $pageIndex,$displayNumber");
    while($row=mysql_fetch_assoc($query))
    {
        $row[img] = get_img($row[id],$table_);
        $arr[]=$row;
    }
    $data=json_encode($arr);
    $s=mysql_errno();
    $good = mysql_query("select id from ".$table_."  where bid='$bid' and score=5");
    $good_num = mysql_num_rows($good);  
    $centre = mysql_query("select id from ".$table_."  where bid='$bid' and (score>=2 and score<=4)");
    $centre_num = mysql_num_rows($centre);  
    $all = mysql_query("select id from ".$table_."  where bid='$bid'");
    $all_num = mysql_num_rows($all);    // 有意思的代码   
    $bid = mysql_query("select id from ".$table_."  where bid='$bid' and score=1");
    $bid_num = mysql_num_rows($bid);    
  
              
    echo "{\\"s\\":$s,\\"data\\":$data,\\"total\\":$total_page,\\"good_num\\":$good_num,\\"centre_num\\":$centre_num,\\"bid_num\\":$bid_num,\\"all_num\\":$all_num}";             
  
    break;
  
  /*
    $all = mysql_query("select id from ".$table_."  where bid='$bid'");
    $all_num = mysql_num_rows($all);    // 有意思的代码   
      这两行代码  现在这样写是好使的
      如果我把它们  放在 $bid_num = mysql_num_rows($bid);  这行代码下面就不好使了 
  
  
  */

网友评论