I am trying to write a small function to display a recordset in
tabular form. I want to define a row only once but then display the
relevant data for each row but I got "undefined variable" when I tried
the following:
I do not necessarily want to display all fields in a recordset so my
row might look like this
$row = "<tr><td>". $rs->Fields[0]->value."</td><td>".$rs->Fields[3]->value."<td></tr>"
while (!$rs->EOF)
{
echo $row;
}
If I define the row like this then the substitution of the variables
takes place immediately and so all rows will be the same as the first.
So what I thought I'd try to do was:
$fldname1 = "rs->Fields[0]->value";
$fldname2 = "rs->Fields[3]->value";
while (!$rs->EOF)
{
$row = "<tr><td>".$$fl dname1."</td><td>".$$fldn ame2."<td></tr>"
}
but here I get an undefined variable :rs->Fields(0)->value error.
I know it looks like I could just put the $row assignment within my
loop in the top example but in fact this row statement is built up
using a more complicated function which I don't want to have to call
for every record as the basic structure will be the same, it's just
the values in the middle that change.
thanks
Phil
tabular form. I want to define a row only once but then display the
relevant data for each row but I got "undefined variable" when I tried
the following:
I do not necessarily want to display all fields in a recordset so my
row might look like this
$row = "<tr><td>". $rs->Fields[0]->value."</td><td>".$rs->Fields[3]->value."<td></tr>"
while (!$rs->EOF)
{
echo $row;
}
If I define the row like this then the substitution of the variables
takes place immediately and so all rows will be the same as the first.
So what I thought I'd try to do was:
$fldname1 = "rs->Fields[0]->value";
$fldname2 = "rs->Fields[3]->value";
while (!$rs->EOF)
{
$row = "<tr><td>".$$fl dname1."</td><td>".$$fldn ame2."<td></tr>"
}
but here I get an undefined variable :rs->Fields(0)->value error.
I know it looks like I could just put the $row assignment within my
loop in the top example but in fact this row statement is built up
using a more complicated function which I don't want to have to call
for every record as the basic structure will be the same, it's just
the values in the middle that change.
thanks
Phil
Comment