php - Display multiple rows as an array -


i want able display table list of people in 1 column , string of orders in another.

people ======== person_id fname lname  orders ======== order_id person_id product_id  products ========= product_id productname 

i have following code:

select people.fname, people.lname, products.productname people inner join orders on people.person_id = orders.person_id inner join products on products.product_id = orders.product_id order lname ... $rows = $result->num_rows; while($row = $result->fetch_assoc()) {     echo "<tr><td>edit</td>     <td>".$row["lname"].", ".$row['fname']."</td>     <td>".$row['productname']."</td></tr>";     } 

this displays:
smith, bob | item 1
smith, bob | item 2
smith, bob | item 3
roberts, jill | item 2
etc..

want display:
smith, bob | item 1, item 2, item 3
roberts, jill | item 2

how show name (based on person_id) once , list of orders in column?

in mysql, have use group_concat function. example this:

select concat(lname,", ",fname), group_concat(productname) people p, products pr, orders o p.person_id = o.person_id , o.product_id = pr.product_id group (lname, fname); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -