Hey all,
Well I got my other problem fixed (some include issues). It all works...but this is a NEW problem.
This is my first time writing up a class in php (never really had a use before).
Right now its a bit messy but check it out.
class News{
var $news;
var $rows;
var $id;
//DisplayNews shows just the table and news
//Can only be called when MySQL connection is called, which happens before this
function DisplayNews($news){
echo" <table cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#000000\" style='width:100%;font-family:Verdana;font-size:12px;'>\n
<tr>\n
<td class=\"tablehead\" height=\"20\">\n
<p><font color=\"#FFFFFF\"><strong>".$this->$rows[title]."</strong></font><br>\n
<font color=\"#CCCCCC\">Posted By ".$rows[author]." on ". date("l dS of F Y @ h:i A", $rows[date])."</font></p></td>\n
</tr>\n
<tr>\n
<td bgcolor=\"#FFFFFF\"><font color=\"#000000\">".$this->body[0]."</tr>\n
<tr><td bgcolor=\"#FFFFFF\"><font color=\"#000000\">".$total_comments." Comments [<a href=\"?comments=view&id=".$rows[id]." \" class=toplink>View</a> | Post]</font></td></tr>\n
</table><p></p>\n";
}
//CleanNews cleans body text and displays only x amount of characters
//on main page until user clicks [more] which displays the WHOLE article
function CleanNews($data, $length){
if(empty($data) || empty($length)){
return "Missing Input Dummy!";
}else{
return GetRecortarTexto(ReplaceText($data), $length); //ReplaceText and GetRecortarTexto is from functions.php
}
}
function DisplayComments(){
}
}
//the main part
if(isset($_GET['id'])){
$obj = new News; //calling the News class
while($rows = mysql_fetch_array($result)){
$obj->DisplayNews($obj->CleanNews($rows[body], $max_length));
}
}
The issue I am having is, I want to pass variables from the while loop into the class so they are displayed, but I can not figure it out for the life of me. I have two books here I have been looking through along with php.net, nothing seems to help me out. I've searched here and havent found anything.
Im sure it is a simple solution (or rather I am hoping).
Im out of ideas...please help _
some of the exsisting variables in this were from old code, and just need to be converted 🙁