At 22:28 19/05/2005 +0000, you wrote:
Message-Id: <[EMAIL PROTECTED]>
From: "John R. Sims, Jr." <[EMAIL PROTECTED]>
To: <php-db@lists.php.net>, <php_mysql@yahoogroups.com>
Date: Thu, 19 May 2005 12:20:24 -0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_NextPart_000_0015_01C55C6D.22CC6B60"
Subject: More problems with a script.  How to I get to a next entry

It allows the case manager to select the client and then it shows them the
case note.  Only problem is that it only shows them one case note, and most
of the clients will have several case notes that have been entered over the
period of the program.

Yeah, you just need to loop your fetch_array request and build the HTML for the notes from that, so :


    $result = mysql_query($result);

 if ($result && mysql_num_rows($result)>0)
 {
   $row = mysql_fetch_array($result);
 }

Becomes


if ($result && mysql_num_rows($result)>0) {

        $result = mysql_query($result);
        $rownumber=0;
        $note_fields='';
        $resultset=array();

        while ($row = mysql_fetch_array($result)) {
                if ($rownumber==0) {
//      Copy the first result, it contains the summary data
                        $resultset=$row;
                }       //      End if
//      And for all rows, concat the notes field as a list item :
                $note_fields .= "<li>" . $row['note'] . "</li>\r\n\t";
//      Now we increment the row number to keep track
                $rownumber++;
        }       //      End while

}       //      End if

<!-- HTML modified to use lists for this sort of information -->

<tr>
        <td>Subject:            </td>
        <td><?=$resultset['subject']?></td>
</tr>
. . . . other HTML rows here using $resultset . . .
<tr>
        <td>Notes:              </td>
        <td>
                <ol>
                        <?=$note_fields?>
                </ol>
        </td>
</tr>

Then just use CSS to style the <ol> list items however you like - bulletted, indented, surrounded by a nice border with a background & margin / padding and so on.

Although that's not the most efficient way to do it, because you're looping the entire recordset just to grab the note from each record - the other attributes of the client record are also sent from the SQL server to the PHP client. If you do that over a network then you've added a few % to the needed bandwidth. Say, if you had 10000 notes per client, it might be something to worry about - though with 10000 notes per client you'd also have *other* things to worry about ;-)

Cheers - Neil



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to