Ben bu anlamaya olamaz. Ben dizilerin bir dizi döndürür basit bir sınıf oluşturmak ettik. Burada sınıf contructor olduğunu ...
class BlogComments {
public $commentArray=array();
public $blogId;
function __construct($inId) {
if(!empty($inId)) {
$this->blogId=$inId;
$sql="select id,name,url,comment,email from blog_comment where blog_id=$inId";
$link2=GetConnection();
$query=mysql_query($sql,$link2) or die("Invalid blog id:".mysql_error());
while($row=mysql_fetch_array($query)) {
$this->commentArray=array(
"id"=>$row['id'],
"name"=>$row['name'],
"url"=>$row['url'],
"email"=>$row['email'],
"comment"=>$row['comment']
);
}
mysql_close($link2);
}
}
}
Ben bir döngü yoluyla dizinin her üyesine erişmek için çalışıyorum. Bu döngü giriyor ancak döndürülen değerleri boş. Ben veri diziye yazılmakta olduğunu doğrulandı. İşte benim kod ...
include "include/commentclass.php";
$comments = new BlogComments($post->id);
foreach($comments as $comment) {
echo "<h4>".$comment->commentArray['name']."</h4>
<a href=\"".$comment->commentArray['url']."\">".$comment->commentArray['url']."</a>
<p>".$comment->commentArray['comment']."</p>";
}
Temelde boş etiketleri döndürür. Ben de $ post-> id geçerli bir değer tutan doğrulandı. Ben ne yapıyorum yanlış Herhangi bir fikir?
Thanks for the help, B