dynamic table limiter
Posted: Tue Feb 01, 2005 6:11 am
Hi all;
Can someone please help me in regards to a dynamic table;
I have a dynamic table which calls the info from a database and then lists all the columns in the specified table using an array.
What I need to do is the following: when it finds an specific column name it needs to perform a substr function on that columns information.
My code to output the dynamic table looks like this so far:
<?php
for($y=0; $y < $dbfield_num; $y++) {
$field_name = mysql_field_name($dbfields, $y);
echo('<td align="left"><span class="c2">'.$row_Recordset1[$field_name].'</span></td>');
}
echo('</tr>');
}
echo('</table></td></tr>');
?>
That works fine in displaying all the information in the specific field but for instance if I try something like this:
<?php
for($y=0; $y < $dbfield_num; $y++) {
$field_name = mysql_field_name($dbfields, $y);
echo('<td align="left"><span class="c2">');
if ($field_name = 'Article') {
substr($Recordset1['Article'],0,50);
}
else
{
echo $row[$field_name];
}
echo ("</span></td>");
}
echo('</tr>');
}
echo('</table></td></tr>');
?>
It doesnt show anything in the table; I'm confused 'cos my thinking is that if it finds the column called 'Article' it will then do the main part of the if statement but I seem to be wrong cos ts not doing this maybe my understanding of the array is incorrect.
Any help would be appreciated
Can someone please help me in regards to a dynamic table;
I have a dynamic table which calls the info from a database and then lists all the columns in the specified table using an array.
What I need to do is the following: when it finds an specific column name it needs to perform a substr function on that columns information.
My code to output the dynamic table looks like this so far:
<?php
for($y=0; $y < $dbfield_num; $y++) {
$field_name = mysql_field_name($dbfields, $y);
echo('<td align="left"><span class="c2">'.$row_Recordset1[$field_name].'</span></td>');
}
echo('</tr>');
}
echo('</table></td></tr>');
?>
That works fine in displaying all the information in the specific field but for instance if I try something like this:
<?php
for($y=0; $y < $dbfield_num; $y++) {
$field_name = mysql_field_name($dbfields, $y);
echo('<td align="left"><span class="c2">');
if ($field_name = 'Article') {
substr($Recordset1['Article'],0,50);
}
else
{
echo $row[$field_name];
}
echo ("</span></td>");
}
echo('</tr>');
}
echo('</table></td></tr>');
?>
It doesnt show anything in the table; I'm confused 'cos my thinking is that if it finds the column called 'Article' it will then do the main part of the if statement but I seem to be wrong cos ts not doing this maybe my understanding of the array is incorrect.
Any help would be appreciated