I have a class i42 and a class news extends i42. The link is coming from the news class. Its pulling the "whatever" value from a database. Here is the code:
class news extends i42
{
function selectbymonth($render)
{
//Query the database and construct months.
//Make the links to ?render=$this->render
echo("$this->render");
//Connect to the database
$this->linked = i42::db_connect();
//Find distinct years (2000, 2001, 2002, etc...)
$this->result = mysql_query("SELECT DISTINCT year FROM $tb_news ORDER BY id DESC");
while($this->row = mysql_fetch_array($this->result))
{
//Find and format the year and echo it
$this->ts = mktime(0,0,0,1,1,$this->row["year"]);
$this->time = date("Y", $this->ts);
echo("<div class=\"update\"><b>".$this->row["year"]."</b><br />\n");
//Find the months in this year
$this->result2 = mysql_query("SELECT DISTINCT month FROM $tb_news WHERE year='$this->row[year]' ORDER BY id DESC") or die(mysql_error());
while($this->row2 = mysql_fetch_array($this->result2))
{
//Find and format the month and echo it
$this->ts = mktime(0,0,0,$this->row2["month"],1,0);
$this->month_a = date("F", $this->ts);
echo("<a href=\"?render=$this->render&year=$this->row[year]&month=$this->row2[month]\">$this->month_a</a><br />\n");
}
echo("</div>\n");
}
}
}
As you can see, the link is coming from the database access. The problem I am having is that those values can't be called from within the class. I've tried putting var and then all the variable names, but it still doesn't work. The only solution I've come upon is this (note that its outside of both classes):
$i42 = new i42;
$i42->render=$render;
Obviously I don't want to have to do that for every variable I pass to the class. Any ideas?