douchun1948 2013-03-27 14:18
浏览 23
已采纳

索引未定义? [关闭]

I am retrieving a row from an SQL table using:

function fetchlevels($Competence_id){
    $this->query="SELECT * FROM levels WHERE comp_id=".$_REQUEST['levels'];
    $tulos=$this->suoritaKysely();
    return $tulos;
}

I call the function in the index using:

 $alllevels=$hr_object->fetchlevels($_GET['levels']);
 $page->assign('alllevels',$alllevels);

and then in my form I want to get the value of one of the columns:

$s=$this->alllevels;
echo $s['lvl2'];

But it tells me that

 Undefined index: lvl2 in C:\www\index\DevIT\forms\hr\competencelevels.php on line 6

However, when using print_r($s) I could see that there is an array with that column!

Array ( [0] => Array ( [id] => 1 [comp_id] => 1 [lvl1] => sas [lvl2] => scc [lvl3] => sxl [lvl4] => lxsi [lvl5] => azix ) )
  • 写回答

1条回答 默认 最新

  • duanran8648 2013-03-27 14:19
    关注

    That value is inside of an array within that array. So, no, it doesn't actually exist. To access it you need to use:

    $s[0]['lvl2'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作