-2

So I came across another problem.

I have this piece of code:

    $query = mysqli_query($mysqli_connect,"
        SELECT profileCode
        FROM personprofile5
        WHERE profileId = '$url'
        LIMIT 30
    ");
    $sqlObject = mysqli_fetch_array($query);
    $output = $sqlObject['profileCode'];
    if(!empty($output)){
        echo count($sqlObject);
        echo '</br></br>';
        print_r($sqlObject);
    } else {
        echo 'This page does not exist.';
    }

The problem is that it should return 2 when echoing the count. And it does, but it's because there is a $sqlObject[0] and a $sqlObject['profileCode'](with the same results) which isn't the way it should be. I want my mysqly to return ALL the values in that column.

So who can help me?

4

1 回答 1

0

首先,您可以使用mysqli_fetch_array()商品参数。如果您只想要一个关联数组,请使用MYSQLI_ASSOC常量作为第二个参数。

之后,如果您想要多个结果,则应循环使用mysqli_fetch_array或使用mysqli_fetch_all

于 2013-07-22T14:54:14.217 回答