echo '<a onclick="load_tags('.$list['id'].')"></a>'
がlist[id]
数字の場合、それは機能します。しかし、list[id]
が単語の場合、それは機能しません。なぜ?
以下は、関数の背景と私が行っていることです。この質問に答える目的には必要ありませんが。
脚本
function load_tags(id){
$.post('../php/tags/get_tags.php',{id:id},function(data){
$('#tags_selected').text(data);
});
}
get_tags.php
$tag_id=$_POST['id'];
echo $tag_id;
$users_with_this_tag=show_all_users_with_this_tag($tag_id);
if(count($users_with_this_tag)!=0){
foreach($users_with_this_tag as $key => $list){
echo $list['user_id'];
}
}else{
echo'Nobody with this tag';
}