rock_14
08-01-2007, 09:35 PM
I am generating a dynamic table and everything works fine except I have the columns hard coded. I need to somehow determine if a column exists in the sense that there is a value in it other than NULL and then change the code below to generate the columns dynamically.
Here is my current code:
<table border=0 align=center cellpadding=5>
<tr>
<td><b>Land</b></td>
<td><b>Acres</b></td>
<td><b>$/Acre</b></td>
<td><b>$/Mile</b></td>
<td><b>Survey</b></td>
<td><b>Township</b></td>
<td><b>Range</b></td>
<td><b>Section</b></td>
<td><b>Block</b></td>
</tr>
<tr>
<td colspan=11>
<hr>
</td>
</tr>
<tr>
<td>
<?
foreach($land_category as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($acres as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($price_per_acre as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($price_per_linear_mile as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($survey as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($township as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($range as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($section as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($block as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
</tr>
The problem again, is that I don't want to display the column title (e.g., Acres) if no value is in the database. Can anyone offer some advice?
Here is my current code:
<table border=0 align=center cellpadding=5>
<tr>
<td><b>Land</b></td>
<td><b>Acres</b></td>
<td><b>$/Acre</b></td>
<td><b>$/Mile</b></td>
<td><b>Survey</b></td>
<td><b>Township</b></td>
<td><b>Range</b></td>
<td><b>Section</b></td>
<td><b>Block</b></td>
</tr>
<tr>
<td colspan=11>
<hr>
</td>
</tr>
<tr>
<td>
<?
foreach($land_category as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($acres as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($price_per_acre as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($price_per_linear_mile as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($survey as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($township as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($range as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($section as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
<td>
<?
foreach($block as $item)
{
if ($item != NULL)
{
print $item.'<br>';
}
}
?>
</td>
</tr>
The problem again, is that I don't want to display the column title (e.g., Acres) if no value is in the database. Can anyone offer some advice?