i'm newb php , mysql. hope have provided enough information below.
table name donations
|========================================================================| | username | game | donation | month | year | time_stamp | id | |========================================================================| | thesquatch | dayz | 5 | june | 2015 | 2015-06-11 00:17:46 | 1 | | themusic | dayz | 20 | july | 2015 | 2015-07-10 03:20:46 | 2 | | sasquatch | dayz | 35 | july | 2015 | 2015-07-10 03:26:04 | 3 | |========================================================================| here current script.
$result = mysqli_query($con,"select username, game, donation, month, year, time_stamp, id donations group year, month order id"); while($row = mysqli_fetch_array($result)) { echo "<center><b>" . ($row['3']) . " " . ($row['4']) . "</b></center>"; echo str_repeat("<center>" . ($row['0']) . " $" . ($row['2']) . " (" . ($row['1']) . ")<br></center>",1 ); } the above code gives me following results.
june 2015 thesquatch $5 (dayz) july 2015 themusic $20 (dayz) i need give me following result. (all donations in month not first one.)
june 2015 thesquatch $5 (dayz) july 2015 themusic $20 (dayz) sasquatch $35 (dayz) if remove "group year, month" following result.
june 2015 thesquatch $5 (dayz) july 2015 themusic $20 (dayz) july 2015 sasquatch $35 (dayz) thanks in advance.
--------------------------------------------------
here final code used result got below.
$result = mysqli_query($con,"select username, game, donation, month, year, time_stamp, id donations order id"); $old_row = 'blank'; while($row = mysqli_fetch_array($result)) { if ($row['3'] . " " . $row['4'] != $old_row) { $old_row = ($row['3'] . " " . $row['4']); echo "<center><b>" . ($row['3']) . " " . ($row['4']) . "</b></center>"; } echo str_repeat("<center>" . ($row['0']) . " $" . ($row['2']) . " (" . ($row['1']) . ")<br></center>",1 ); } the result.
june 2015 thesquatch $5 (dayz) july 2015 themusic $20 (dayz) sasquatch $35 (dayz) --------------------------------------------------
$result = mysqli_query($con,"select username, game, donation, month, year, time_stamp, id donations order id"); $old_row = 'blank'; while($row = mysqli_fetch_array($result)) { if ($row['3'] . " " . $row['4'] != $old_row) { $old_row = ($row['3'] . " " . $row['4']); echo "<center><b>" . ($row['3']) . " " . ($row['4']) . "</b></center>"; } echo str_repeat("<center>" . ($row['0']) . " $" . ($row['2']) . " (" . ($row['1']) . ")<br></center>",1 ); }
Comments
Post a Comment