mysql - PHP: Building an HTML Table from an Array with Repeated Entries -
I have a database table (created by query) that lists the member (called a truppe), event, startup Date and end date A member can be listed more than once in the table because they are associated with more than one event.
I want to create an HTML table that lists the name of that member, after which they are associated with each event for the next member, which may contain some items in the array.
I was thinking of using a foreach ()
statement but could not get it to work. Any sign on how I can accomplish this? Thanks!
while (list ($ event, $ troupe, $ start-date, $ termination) = mysqli_fetch_array ($ result)) {$ return = $ return "& lt; table & gt;" ; $ Return = $ return "& lt; tr & gt;"; $ Return = $ refund "& lt; th colspan = 3" gt; ". $ Troop" & lt; / Th & gt; "; $ return = $ return" & lt; / TR & gt; "$ return = $ return" & lt; TR & gt; "$ return = $ return" & lt; Th & gt; Event & lt; / Th & gt; "; $ return = $ return" & lt; Th & gt; Start date & lt; / Th> "$ return = $ return" & lt; Th & gt; End Date & lt; / Th> "$ return = $ return" & lt; / TR & gt; "// // Foreign Currency ($ trupo $ this form of trupo) {$ return = $ return" & LT; TR & gt; "$ return = $ return" & lt; TD & gt; ". $ Program" & lt; / TD> "$ return = $ return" & lt; TD & gt; "$ start-date" & lt; / TD> "$ return = $ return" & lt; TD & gt; ". $ End date" & lt; / TD> "$ return = $ return" & lt; / TR & gt; "; // $ return = $ return" & lt; / TR & gt; "$ return = $ return" & lt; / Table & gt; ";}
Change your code with this mandatory That the SQL result is sorted by the truppe.
$ return = ''; $ CurrentTroop = ''; while (list ($ event, $ trupo, $ start date, $ expiration date) = Mysqli_fetch_array ($ result)) {if ($ currentTroop! = $ Troop) $$. = "& Lt; Table & gt; "." & Lt; TR & gt; ";." & Lt; Th colspan = 3 & gt; ". $ Troop" & lt; / Th & gt; "." & Lt; / TR & gt; "." & Lt; TR & gt; "." & Lt; Th & gt; Event & lt; / Th & gt; "." & Lt; Th & gt; Start Date & lt; / Th & gt; "." & Lt; Th & gt; End date & lt; / Th & gt; "." & Lt; / TR & gt; ";} $ return. =" & Lt; Tr & gt; "." & Lt; TD & gt; "$ Event" & lt; / TD & gt; "..." & Lt; TD & gt; "$ StartDate .." & lt; / TD> "." & Lt; TD & gt; "$ endDate .." & lt; / TD> "." & Lt; / TR & gt; "; if ($ currentTroop! = $ Troop) {$ return. =" & Lt; / Tr & gt; "." & Lt; / Table & gt; "; $ CurrentTroop = $ Troop;}}
Comments
Post a Comment