djackson88
02-17-2009, 07:20 PM
Hello All,
I am trying to manipulate the way my mysql table data displays on my PHP page. Here is my setup:
Mysql table called orders
Fields:
* custnum
* fname
* lname
* item
* qty
* date
When a customer places the order an entry is made to the table for each item purchased so in my example, Customer A made 3 purchases so this would be in the table.
1001 First Name Last Name Shoes 1 2/17/2009
1001 First Name Last Name Socks 2 2/17/2009
1001 First Name Last Name Laces 2 2/17/2009
I am using PHP to display this order information for order history purposes. Right now I have a while loop that just prints out the table exactly as it is above into a html table in a browser that looks like this
<table>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Shoes</td><td>1</td><td>2/17/2009</td>
</tr>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Socks</td><td>2</td><td>2/17/2009</td>
</tr>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Laces</td><td>2</td><td>2/17/2009</td>
</tr>
</table>
Now for my question, is there a way that I can print out my table into a php/html table where instead of creating three seperate lines for the same customer it will only print one line that looks like this (this is assuming each customer will ALWAYS have three items purchased at the same time, no more, no less):
<table>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Shoes</td><td>1</td><td>Socks</td><td>2</td><td>Laces</td><td>2</td><td>2/17/2009</td>
</tr>
</table>
I am trying to manipulate the way my mysql table data displays on my PHP page. Here is my setup:
Mysql table called orders
Fields:
* custnum
* fname
* lname
* item
* qty
* date
When a customer places the order an entry is made to the table for each item purchased so in my example, Customer A made 3 purchases so this would be in the table.
1001 First Name Last Name Shoes 1 2/17/2009
1001 First Name Last Name Socks 2 2/17/2009
1001 First Name Last Name Laces 2 2/17/2009
I am using PHP to display this order information for order history purposes. Right now I have a while loop that just prints out the table exactly as it is above into a html table in a browser that looks like this
<table>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Shoes</td><td>1</td><td>2/17/2009</td>
</tr>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Socks</td><td>2</td><td>2/17/2009</td>
</tr>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Laces</td><td>2</td><td>2/17/2009</td>
</tr>
</table>
Now for my question, is there a way that I can print out my table into a php/html table where instead of creating three seperate lines for the same customer it will only print one line that looks like this (this is assuming each customer will ALWAYS have three items purchased at the same time, no more, no less):
<table>
<tr>
<td>1001</td><td>First Name</td><td>Last Name</td><td>Shoes</td><td>1</td><td>Socks</td><td>2</td><td>Laces</td><td>2</td><td>2/17/2009</td>
</tr>
</table>