Ok, I have a simple class that I will use for javascript based client side paging. For some reason my class is setting all the class variables to the same value when any one of them is set. Am I loosing my mind?
Here is the code:
<?php
class ClientPaging{
var $rowsPerPg;
var $currentPg;
var $numCols;
var $numRecs;
var $maxPg;
var $qry;
function ClientPaging($rows=10, $qry=""){
$this->$rowsPerPg = $rows;
$this->$currentPg = 1;
$this->$numCols = 0;
$this->$numRows = 0;
$this->$maxPg = 0;
$this->$qry = $qry;
if ($qry <> "")
$this->initalize($qry);
}
function initalize($qry){
//The db_connect here is in a seperate file, it works.
if(!$conn = db_connect()){
echo "No connection";
return false;
}
else
{
$result = mysql_query($qry) or die('Error, query failed');
//The qry I am using returns 22 rows and 4 cols
$this->$numCols = mysql_num_fields($result);
$this->$numRows = mysql_num_rows($result);
$this->maxPg = ($this->$numRows/$this->$numCols);
}
//So I should see
//10
//4
//22
echo $this->$rowsPerPg."<BR>";
echo $this->$numCols."<BR>";
echo $this->$numRows;
}
}
But
When instantiated I get this:
22
22
22
Any one see something I'm missing?
Here is the code:
<?php
class ClientPaging{
var $rowsPerPg;
var $currentPg;
var $numCols;
var $numRecs;
var $maxPg;
var $qry;
function ClientPaging($rows=10, $qry=""){
$this->$rowsPerPg = $rows;
$this->$currentPg = 1;
$this->$numCols = 0;
$this->$numRows = 0;
$this->$maxPg = 0;
$this->$qry = $qry;
if ($qry <> "")
$this->initalize($qry);
}
function initalize($qry){
//The db_connect here is in a seperate file, it works.
if(!$conn = db_connect()){
echo "No connection";
return false;
}
else
{
$result = mysql_query($qry) or die('Error, query failed');
//The qry I am using returns 22 rows and 4 cols
$this->$numCols = mysql_num_fields($result);
$this->$numRows = mysql_num_rows($result);
$this->maxPg = ($this->$numRows/$this->$numCols);
}
//So I should see
//10
//4
//22
echo $this->$rowsPerPg."<BR>";
echo $this->$numCols."<BR>";
echo $this->$numRows;
}
}
But
When instantiated I get this:
22
22
22
Any one see something I'm missing?