从sql查询中打印出别名

时间:2015-01-02 14:35:53

标签: php sql mysqli

我试图回复NumNotNull列并不确定我是如何尝试使用$ row [' NumNotNull']并没有真正解决问题

if($result = $conn->query($sql)){
$champ_number = $result->num_rows;
$i = 1;
$champion = array();
$noofspellschamp = array();
while($row = $result->fetch_assoc()){

    $champion[$i]=$row['champion'];

    $sql2 = "
    SELECT Passive, Q, W, E, R,
            ((Passive is not null) + (Q is not null) + (W is not null) + (E is not null) + (R is not null)
            ) as NumNotNull
    FROM champions
    WHERE Patch_No ='".$_GET['Patch_No']."' AND
          Champion = ".$row['champion']."";
    $result2 = $conn->query($sql2);
    echo $result2;
    $noofspellschamp[$i] = $result2;                            

    $i+=1;
    //echo $champion[count($row)];

修改

var_dump($result2);

节目 布尔值假 布尔值假 由于没有工作,我的意思是什么都没有显示

EDIT3 现在没有错误,这是我用var_dump得到的

 object(mysqli_result)[2]
 public 'current_field' => null
 public 'field_count' => null
 public 'lengths' => null
 public 'num_rows' => null
 public 'type' => null
  object(mysqli_result)[5]
  public 'current_field' => null
  public 'field_count' => null
  public 'lengths' => null
  public 'num_rows' => null
  public 'type' => null

0 个答案:

没有答案