我想将mysql_fetch_array()的结果数组传递给javascript函数。无法将php数组转换为javascript函数
这是一个代码。
<?php
$msDetails= mysql_query("select * from article_master where status='complete'") or die(mysql_error());
while ($row= mysql_fetch_array($msDetails)) {
$co_auth_name=mysql_query("select fname from author_detail where journal_id='$jid' && article_id='$row[1]' && (correspondng_author != 'on' || correspondng_author = 'false')");
$num=mysql_affected_rows();
echo $num; //2
while ($co_auth=mysql_fetch_array($co_auth_name))
{
$JArray= json_encode($co_auth);;
echo $JArray;
}
?>
<tr>
<td><a href="javascript:popup_viewReports('<?php echo $JArray ?>');">View</a>
</td>
</tr>
<?php
}
?>
如何将$ co_Auth传递给viewReports()?
的[传递一个PHP数组JavaScript函数]可能重复(http://stackoverflow.com/questions/4885737/pass-a-php-array-to-a-javascript-function) – SuperSaiyan 2013-04-30 10:26:45
另外,使用'$ JArray [] = $ co_auth;',然后在循环之后使用json_encode。 – SuperSaiyan 2013-04-30 10:28:46