Well tried doing this in my code and it didn't work. So i tried it using just a simple page and it did work. I'm baffled.
here is my code:
<html>
<body>
<?php
// start definitions
class Field
{
var $name;
var $label;
var $size;
var $maxchar;
var $type;
var $validationrule;
function Field ($name, $type,$label, $size, $maxchar, $validationrule) {
$this->name = $name;
$this->type = $type;
$this->label=$label;
$this->size=$size;
$this->maxchar=$maxchar;
$this->validationrule=$validationrule;
}
}
class Table
{
var $fields = array();
var $linkedMySQLDB;
var $linkedMySQLTable;
function addField($field)
{
$this->fields[] = $field;
}
function printFieldHTML($n)
{
$v=$this->fields[$n];
echo "<table width='300' border='0'><tr><td width='50%'>";
printf ("%s ",$v->label);
echo "</td><td width='50%'>";
printf ("<input type='%s' name='%s' size='%s' maxchar='%s' value='%s'><BR>",$v->type,$v->name,$v->size,$v->maxchar,${$v->name});
echo "</td> </tr></table>";
}
}
// end definitions
$table2 = new Table();
// ($name, $label, $size, $maxchar, $type, $validationrule)
$table2->linkedMySQLTable = "UserReg";
$table2->addField(new Field('username','text','User name:','10','10','NO NULL'));
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF?>">
<?php
$table2->printfieldHTML(0);
echo "<BR>";
echo "<BR><BR>";
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Originally posted by LordShryku
variable variables
$var = "blah";
$blah = "hello";
echo ${$var}; // echos hello
[/B]