douse8732 2013-07-22 14:44
浏览 6
已采纳

Mysqli没有返回正确的元素

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?

  • 写回答

1条回答 默认 最新

  • dsajkdadsa14222 2013-07-22 14:54
    关注

    First you may use mysqli_fetch_array() with goods parameters. If you only want an associative array use MYSQLI_ASSOC constant as second parameter.

    After if you want more than one result you should loop on mysqli_fetch_array or use mysqli_fetch_all

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程