kemper Posted April 11, 2008 Share Posted April 11, 2008 With the great weather we have had this year so far, I have a list of closed fields that is displayed as: Date 1 - Field Date 1 - Another Field Date 1 - Yet Another Field ----------------------- Date 2 - Field Date 2 - Another Field Date 2 - Yet Another Field I would like it to display as: Date 1 - Field Another Field Yet Another Field ----------------------- Date 2 - Field Another Field Yet Another Field echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td bgcolor='#FFFF00'> <p align='center'><font color='#FF0000'><b>".$locale['fs005']."</b></font> <table border='0' width='100%' id='table1'> </tr>\n"; while ($data = dbarray($sql)) { $i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2"; if ($data['dates'] != $prev) { // if changed echo "<tr><td colspan='3'><hr></td></tr>\n"; // blank row $prev = $data['dates']; } echo "<tr> <td nowrap valign='top'> <font color='#0000FF' size='1'>".$data['dates']." -</td><td>".$data['fields']."</font></td> </tr>\n"; } echo "</table> <p align='center'><font color='#FF0000'>".$locale['fs006']."</font></td></tr> </table>\n"; How do I alter? Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/ Share on other sites More sharing options...
poleposters Posted April 11, 2008 Share Posted April 11, 2008 Hey Kemper this is a HTML problem. Basically you need you need to set up a table like so <table> <tr><th>Date</th></tr> <tr><td>Field</td></tr> <tr><td>Another Field</td></tr> <tr><td>Yet another field</td></tr> </table> Of course you will need to insert this appropriately into your PHP script Its a good practise to create a HTML page with dummy data first to test the look and feel of your page and then insert it into your PHP script. It saves alot of time and becomes less confusing. Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-514516 Share on other sites More sharing options...
kemper Posted April 11, 2008 Author Share Posted April 11, 2008 Well, I have tried to Tried to change the makeup of the <table> and Date was not displaying. Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-514708 Share on other sites More sharing options...
poleposters Posted April 11, 2008 Share Posted April 11, 2008 post your modified code Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-514745 Share on other sites More sharing options...
kemper Posted April 11, 2008 Author Share Posted April 11, 2008 echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td bgcolor='#FFFF00'> <p align='center'><font color='#FF0000'><b>".$locale['fs005']."</b></font> <table border='0' width='100%' id='table1'> </tr><tr><td align='center'><b>".$data['dates']."</b></td></tr>\n"; while ($data = dbarray($sql)) { $i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2"; if ($data['dates'] != $prev) { // if changed echo "<tr><td colspan='3'><hr></td></tr>\n"; // blank row $prev = $data['dates']; } echo "<tr> <td valign='top'> <font color='#0000FF' size='1'>* ".$data['closures']."</font></td> </tr>\n"; } echo "</table> <p align='center'><font color='#FF0000'>".$locale['fs006']."</font></td></tr> </table>\n"; } else { echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td bgcolor='#FFFF00'><center><br>\n".$locale['fs007']."<br><br></td></tr></table>\n</center>\n"; Code not displaying ".$data['dates'].". Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-515179 Share on other sites More sharing options...
BlueSkyIS Posted April 11, 2008 Share Posted April 11, 2008 does $data['dates'] have anything in it? are you retrieving a field called 'dates'? it would help to see the code before the bit you posted. Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-515225 Share on other sites More sharing options...
kemper Posted April 12, 2008 Author Share Posted April 12, 2008 See originating post. 'dates' field contains the specific weekend that it applies to. Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-515293 Share on other sites More sharing options...
poleposters Posted April 12, 2008 Share Posted April 12, 2008 Try putting the array into corresponding variables before you print them. It could be a proble with your quote marks. ie $closures=$data['closures']; print "<td>$closures</td>"; If the date is not displaying when you type print "$data['dates']"; It could be a problem with your query or the field in the database could be blank. Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-515418 Share on other sites More sharing options...
kemper Posted April 12, 2008 Author Share Posted April 12, 2008 That field is not blank. It appears when I code it as <tr><td>".$data['dates']." -</td><td>".$data['fields']."</td></tr> So must be my query. How can I remedy? Quote Link to comment https://forums.phpfreaks.com/topic/100584-list-display-by-topic/#findComment-515532 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.