function showchapsingle($truyen_id){
global $wpdb,$post;
$list=$wpdb->get_results("SELECT episode_id, episode_name, episode_type, episode_url, episode_film FROM
wp_film_episode WHERE episode_film = '".$truyen_id."' ");
foreach ( $list as $value )
{
$episode_type=$value->episode_type;
$name=$value->episode_name;
$tap=$value->episode_id;
$phim=$value->episode_film;
$chap_url = get_permalink($phim).'?ep='.$tap.'';
echo " <table>
<tr>
<td><a href=\"".$chap_url."\" title=\"".$name."\">".$name."</a></td>
<td>Displays the name author<Example: Admin, member...></td>
<td>Displays time post.</td>
</tr>
</table>
";
}
}
我希望它显示如下:
答案 0 :(得分:1)
每次从MYSQL查询中获取值(行)时,都在创建表。
请移动echo "<table>
&amp; echo "</table>
之前和之后的foreach
。
如果有任何疑问,请发表评论,我会适当地编辑我的答案:)
完整代码
function showchapsingle($truyen_id){
global $wpdb,$post;
$list=$wpdb->get_results("SELECT episode_id, episode_name, episode_type, episode_url, episode_film FROM
wp_film_episode WHERE episode_film = '".$truyen_id."' ");
echo "<table><tr><th>Chapter Name</th><th>Author Name</th><th>Time</th></tr>";
foreach ( $list as $value )
{
$episode_type=$value->episode_type;
$name=$value->episode_name;
$tap=$value->episode_id;
$phim=$value->episode_film;
$chap_url = get_permalink($phim).'?ep='.$tap.'';
echo "<tr><td><a href=\"".$chap_url."\" title=\"".$name."\">".$name."</a></td> <td>The Author</td> <td>Displays time post.</td></tr>";
}
echo "</table>";
}