Page 1 of 1

[SOLVED] Generate Table Using Loop

Posted: Wed Oct 13, 2010 1:53 am
by Bbob
Hi Im having trouble with this code

Code: Select all


$get = mysql_query("
						SELECT requestdate, itemname, businessname, itemid 
						FROM tempoq t 
						LEFT JOIN customerinfo c 
						ON t.customerid = c.customerid 
						ORDER BY requestdate
					  ") or die (mysql_error()); 

while ($row = mysql_fetch_assoc($get)) 
        {
           if ($row['requestdate'] != $currentDate) 
           {
                        echo "<table class=listing cellpadding=0 cellspacing=0 border=0>";
                        echo "<tr>";
                        echo "<th>".$row['requestdate']."</th>";
                        echo "</tr>";
                        
                        $currentDate = $row['date'];
           }
                        echo "<tr>";
                        echo "<td>" .$row['itemid']. "</td>";
                        echo '<td><a href = "quoteitem?label='.$row['itemid'].'">'.$row['itemname']."</a></td>";
                        echo "<td>" .$row['businessname']."</td>";
                        echo "</tr>";
                        
                        echo "</table>"; 
                        
           
        }

Im trying to get this output.


10 - 13 -2010
1 | Paper | Paper Maker
2 | Ink | Ink Maker

10 - 14 - 2010
3 | Chair | Chair Maker

Re: Generate Table Using Loop

Posted: Wed Oct 13, 2010 8:14 am
by twinedev
Two things.

1. You are reading in requestdate but you are setting $currentdate = $row['date'];
2. You are closing the table after each record, where it needs to be left open.

-Greg

Re: Generate Table Using Loop

Posted: Wed Oct 13, 2010 8:33 am
by Bbob
Hi

Thanks for the reply.

It worked :D


Thanks you so much!