[SOLVED] Generate Table Using Loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bbob
Forum Commoner
Posts: 57
Joined: Sat Aug 07, 2010 4:46 am

[SOLVED] Generate Table Using Loop

Post 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
Last edited by Bbob on Wed Oct 13, 2010 8:35 am, edited 1 time in total.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Generate Table Using Loop

Post 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
Bbob
Forum Commoner
Posts: 57
Joined: Sat Aug 07, 2010 4:46 am

Re: Generate Table Using Loop

Post by Bbob »

Hi

Thanks for the reply.

It worked :D


Thanks you so much!
Post Reply