Jump to content

list display by topic


kemper

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

	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'].".

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.