2014-10-01 33 views
-5
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> 
     "; 
     } 
     } 

我希望它會顯示這樣的:請幫我有關函數在PHP中:

enter image description here

+1

請張貼error_log中。 – 2014-10-01 14:07:06

+1

你有什麼嘗試?你遇到了什麼錯誤?你做過任何研究嗎? – 2014-10-01 14:07:33

+0

你現在得到什麼結果? – 2014-10-01 14:08:53

回答

1

您從MySQL查詢使每一個你得到一個值(行)時表。

請移動echo "<table> & echo "</table>之前和之後foreach rietly。

如果有任何疑問,請評論,我會編輯我的答案:)適當

全碼

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>"; 
     } 
+0

請爲我示例。 Php我不好。 – 2014-10-01 14:43:48

+0

@Jonhson但作者姓名和時間存儲在哪裏? – 2014-10-01 14:53:59

+0

作者名稱使用:<?php the_author();?> wordpress – 2014-10-01 15:10:16