| Frames | Modems | Help | Home Page | Chipsets | Search | No Frames |
| Diary Entries | See also Site Info & Diary. | |
| 18 January 2002 | The use of PHP variable Variables... | |
Here's the problem:
|
||
| This wasn't academic for me - one actual example is the Dead field in names (see 14 Jan for the tables & 18 Dec for the Forms class). Creating the Form controls is easy: $dRad1=new Radio("nDead", 1);
$dRad1->acc="Y";
$dRad1->lab="Yes";
$dRad0=new Radio("nDead", 0);
$dRad0->acc="N";
$dRad0->lab="No";
$dRad0->rt=TRUE;
...
$dRad1->show()." ".$dRad0->show()
All well & good so far, but what happens when you want to display multiple rows from the same table and allow changes? The first thought is perhaps to use something like the following: $cHid=new Hidden("nid[]", NULL);
$r=mysql_query($s);
while(list($cHid->val,$val)=mysql_fetch_row($r)) {
$dRad1->chk=($val)?TRUE:NULL;
$dRad0->chk=($val)?NULL:TRUE;
...
$dRad1->show()." ".$dRad0->show()
}
while(list($cHid->val,$val)=mysql_fetch_row($r)) {
$dRad1->nam=$dRad0->nam="nDead".$cHid->val;
$dRad1->chk=($val)?TRUE:NULL;
$dRad0->chk=($val)?NULL:TRUE;
...
$dRad1->show()." ".$dRad0->show()
}
while(list($key,$val)=each($nName)) {
$r="nDead".$nid[$key];
$q=(($nid[$key])?"UPDATE":"INSERT INTO").
...
", Dead=".((!$$r)?"NULL":"1").
(($nid[$key])?" WHERE NID=$nid[$key]":"");
mysql_query($q);
}
|
||