akabod Posted November 13, 2010 Share Posted November 13, 2010 I'm trying to write a php page that displays data from a JOIN query for a specific ID table view brandinfo ID, brand, discounttype 1, antioni, no discount brandproducts brandID, producttype, price 1, Tshirt, 20.00 1, Pants, 30.00 1, Shoe, 40.00 the returned result is 1 antioni, no discount, Tshirt, 20.00, 2 antioni, no discount, Pants, 30.00 3 antioni, no discount, Shoe 40.00 The way I want the page to be displayed is ------------------ Antioni (at the top) Table 1. Tshirt 20.00 2. Pants 30.00 3. Shoe 40.00 no discount (at the bottom) ---------------------------- How should I construct the PHP page from the result since they're retrieved as rows? Link to comment https://forums.phpfreaks.com/topic/218581-php-page-layout-when-query-result-returns-multiple-rows/ Share on other sites More sharing options...
possien Posted November 13, 2010 Share Posted November 13, 2010 It may not be the best way but I recently did something similar by nesting while statements from 3 queries: while($row = mysqli_fetch_array($name)){ //Display name while($row = mysqli_fetch_array($data)){ //display data while($row = mysqli_fetch_array($discount)){ // display discount Link to comment https://forums.phpfreaks.com/topic/218581-php-page-layout-when-query-result-returns-multiple-rows/#findComment-1133854 Share on other sites More sharing options...
akabod Posted November 13, 2010 Author Share Posted November 13, 2010 It may not be the best way but I recently did something similar by nesting while statements from 3 queries: while($row = mysqli_fetch_array($name)){ //Display name while($row = mysqli_fetch_array($data)){ //display data while($row = mysqli_fetch_array($discount)){ // display discount Thanks! That's exactly what I'm looking for. Link to comment https://forums.phpfreaks.com/topic/218581-php-page-layout-when-query-result-returns-multiple-rows/#findComment-1133874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.