douren9077 2015-04-01 19:01
浏览 51

如何在jquery零件代码中格式化多个数组(php)的一个元素

When i Login this part of the code is executed:

 $_SESSION['user'] = array('user_id' => $user[0]['user_id'], 'IP' => $_SERVER['REMOTE_ADDR']);

now on the upfollowing php page this code has to read the user_id

 $.tablesorter.setFilters( table, ['', '<?=$_SESSION["favcolor"];?>'  ], true);

where 'favcolor' is, needs the 'user_id' be...

but how do i format that?

i thought it was like so: (i got that idea from this site, i thougth it was a Multi array http://www.w3schools.com/php/php_arrays_multi.asp )

 '<?=$_SESSION[0][1];?>'

but that does not work..

so how should it be formated then?

pls help

almost there, only the word 'ARRAY' is now in the column

$.tablesorter.setFilters( table, ['', '<?=$_SESSION["user"];?>'  ], true);
  • 写回答

1条回答 默认 最新

  • doumei1955 2015-04-01 19:31
    关注

    You can use $_SESSION['user']['user_id'] to access user_id from the $_SESSION array.

    In this :

    $.tablesorter.setFilters( table, ['', '<?=$_SESSION["user"];?>'  ], true);
    

    You are getting ARRAY because $_SESSION["user"] is really an array containing user_id and IP. You need to specify the index user_id for retrieving the value of user_id from that.

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?