Click to See Complete Forum and Search --> : Dynamic tables


kproc
11-13-2006, 08:41 AM
Hi

I have been working quite a bit with dynamic tables. I'm mixed between two way of creating the table.

I started buy using a while statement

something like this



echo '<table>';
while ($row_get_gifts = mysql_fetch_assoc($sql_get_gifts){

echo '<table>';

echo '<tr><td>name</td><td>$row_get_gifts['name']</td><tr>';
}
echo '</table>;


Displays nothing on dreamweaver

I tryed the tool to create the table using dreamweavers built in feature.
and it takes a different approach wich display the table on the design page which I like because it displays the table on the design page.

The problem is it creates a blank entry which I don't want.

any thought on what approach is best

How it does it


<table class="columntable">

<tr>
<td colspan="2" class="tableheader">Buddy Gifts</td>
</tr>

<?php do { ?>

<tr>
<td class="border">Occasion</td>
<td class="border"><?php echo $row_get_gifts['occasion']; ?></td></tr>

<?php } while ($row_get_gifts = mysql_fetch_assoc($sql_get_gifts)); ?>
</table>

scousesheriff
11-13-2006, 08:50 AM
It is creating a blank entry because the first time it gets to:
$row_get_gifts['occasion'];
in the do..while loop, $row_get_gifts doesnt hold any data. You need to call:
$row_get_gifts = mysql_fetch_assoc($sql_get_gifts)
before the loop starts. Or change it back into a while loop like so:
<table class="columntable">

<tr>
<td colspan="2" class="tableheader">Buddy Gifts</td>
</tr>

<?php while ($row_get_gifts = mysql_fetch_assoc($sql_get_gifts)) { ?>

<tr>
<td class="border">Occasion</td>
<td class="border"><?php echo $row_get_gifts['occasion']; ?></td></tr>

<?php } ?>
</table>
Hope this helps.