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
dynamic table limiter
Moderator: General Moderators
this line
should be...
Code: Select all
if ($field_name = 'Article') {Code: Select all
if ($field_name == 'Article') {thats better
Howzit going that seems to be better but the only problem now is that its not showing anything in the article field; would you know why so all the other colmns show info but the article column is empty even though there's data in the table for it.
this is the code for it
Is there something I'm missing ?
Thanks again
this is the code for it
Code: Select all
if ($field_name == 'Article') {
substr($field_nameї'Article'],0,50);
}
else
{
echo $rowї$field_name];
}Thanks again
try
Code: Select all
echo substr($field_nameї'Article'],0,50);