2012-02-13 21 views
0
<?php  

    $res=$comments->result_array(); 
    $i=1; 
    $ar=array(); 
    foreach($res as $row){ 
     $a=array($i,$row['title'],$row['date_post'], 
      $row['date_edit'], 
      '<a href="edit_post?title='.$row['title'].'">Edit</a>', 
      '<a href="delete_post?title='.$row['title'].'">Delete</a>'); 
     array_push($ar,$a); 
     $i++; 
    }  
    echo $this->table->generate($ar); 
    echo $this->pagination->create_links(); 
?> 

我已經添加了兩個鏈接(編輯和刪除)進入我的頁面,這個職位之前由該href issue in view-controler協助我固定的URL和創建鏈接請

上一篇解決方案使我更加困惑來處理上面的源代碼片段中創建的每個鏈接的URL,例如http://localhost/blog/get_comments/edit_post?title=something/,而我期望像http://localhost/blog/edit_post?title=something之類的東西。我很感激任何幫助。謝謝。

UPDATE

,直到我點擊編輯或在上面的代碼,這是解析URL爲http://localhost/blog/get_comments/edit_post?title=something/,而我希望像http://localhost/blog/edit_post?title=something創建刪除鏈接上面的代碼工作正常。因爲他們似乎是相對

+0

您的問題是非常不清楚。你能說清楚一點嗎? – 2012-02-13 07:45:02

+0

是的,我按照你的建議編輯它 – user1125233 2012-02-13 07:54:15

回答

1

更改網址...

'<a href="edit_post?title='.$row['title'].'">Edit</a>', 
'<a href="delete_post?title='.$row['title'].'">Delete</a>'); 

應該是:

'<a href="http://localhost/blog/edit_post?title='.$row['title'].'">Edit</a>', 
'<a href="http://localhost/blog/delete_post?title='.$row['title'].'">Delete</a>'); 

如果僅會出現在一個地方,那麼你也許能夠逃脫與:

'<a href="../edit_post?title='.$row['title'].'">Edit</a>', 
'<a href="../delete_post?title='.$row['title'].'">Delete</a>');