rushhh
03-08-2009, 10:37 PM
Hi everyone. I'm fetch data from mysql then displaying it into 2 html tables.
The data in the mysql is:
Banana, 2 LBS
Creme, 2 LBS
Brownie, 2 LBS
Batter, 2 LBS
Blueberry, 2 LBS
Milk, 2 LBS
Brownie, 5 LBS
Batter, 5 LBS
Blueberry, 5 LBS
Milk, 5 LBS
Tring to get it to display as
2 LBS
Banana Creme
Brownie Batter
Blueberry Milk
5 LBS
Brownie Batter
Blueberry Milk
Right now in table "2 LBS" it displays everything that in "2 LBS", but in table "5 LBS"
it disaplays 4 names of "2 LBS" , how can I get table "5 LBS" to only
display what in "5 LBS"?
Here my code:
[CODE]
$query=mysql_query("select size from $tb4_name WHERE product_id='$uid' Group by size");
while($order=mysql_fetch_row($query))
while (list ($key, $val) = each ($order)){
echo $val; //echo the sizes "2 LBS" and "5 LBS" to make the header of the tables
$query2=mysql_query("SELECT * FROM $tb4_name WHERE product_id='$uid' and size = '$val' ORDER BY size, name");
$count = mysql_num_rows($query2);
while ($row1=mysql_fetch_array($query2)) {
$array1[] = ($row1['name']);
echo "<table border='1' width='250'>";
for($i = 1; $i <= $count; $i = $i + 2)
{
echo "<tr><td>{$array1[$i]}</td><td>{$array1[$i+1]}</td></tr>";
}
echo "</table>";
}}
[CODE]
Thanks
The data in the mysql is:
Banana, 2 LBS
Creme, 2 LBS
Brownie, 2 LBS
Batter, 2 LBS
Blueberry, 2 LBS
Milk, 2 LBS
Brownie, 5 LBS
Batter, 5 LBS
Blueberry, 5 LBS
Milk, 5 LBS
Tring to get it to display as
2 LBS
Banana Creme
Brownie Batter
Blueberry Milk
5 LBS
Brownie Batter
Blueberry Milk
Right now in table "2 LBS" it displays everything that in "2 LBS", but in table "5 LBS"
it disaplays 4 names of "2 LBS" , how can I get table "5 LBS" to only
display what in "5 LBS"?
Here my code:
[CODE]
$query=mysql_query("select size from $tb4_name WHERE product_id='$uid' Group by size");
while($order=mysql_fetch_row($query))
while (list ($key, $val) = each ($order)){
echo $val; //echo the sizes "2 LBS" and "5 LBS" to make the header of the tables
$query2=mysql_query("SELECT * FROM $tb4_name WHERE product_id='$uid' and size = '$val' ORDER BY size, name");
$count = mysql_num_rows($query2);
while ($row1=mysql_fetch_array($query2)) {
$array1[] = ($row1['name']);
echo "<table border='1' width='250'>";
for($i = 1; $i <= $count; $i = $i + 2)
{
echo "<tr><td>{$array1[$i]}</td><td>{$array1[$i+1]}</td></tr>";
}
echo "</table>";
}}
[CODE]
Thanks