這是代碼:我無法從php數組中檢索值
我無法在第二個功能中打印站點類型。發送「所有」從不同的功能參數時,我能夠打印陣列。
function site_type_find($site_type)
{
$site_type_name_array=['Youtube','Wikipedia','Mashable','Wired'];
if($site_type="all")
return $site_type_name_array;
else
return $site_type_name_array[$site_type];
}
function display_topic_category_sitetype($topic_id,$category_id,$site_type)
{
$result=mysql_query("select topic_name from topic_table where topic_id=$topic_id");
$result1=mysql_query("select category from categorytable where category_id=$category_id");
$site_type_name=site_type_find($site_type);
$resultarr=array();
$resultarr1=array();
$resultarr=mysql_fetch_array($result);
$resultarr1=mysql_fetch_array($result1);
$topic=$resultarr[0];
$catname=$resultarr1[0];
?>
<section>
<header><?php echo $topic."\n";?></header>
<article><?php echo $catname."\n";?></article>
<article><?php echo $site_type_name."\n";?></article>
<?php
}
比較謝謝的回答!不能想出這麼簡單的事! :( – Aravind 2013-04-09 08:10:31