Re: Need help with display of results
| From: | Lars Torben Wilson | Date: | Sat, 07 Jun 2003 01:45:53 +0000 |
| Subject: | Re: Need help with display of results | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150558@lists.php.net to get a copy of this message | ||
On Fri, 2003-06-06 at 14:32, Gloria L. McMillan wrote:
> Hi, again!
>
> I did not see my question as yet so I will repost it.
>
> I have had help writing HTML code to display the results of my PHP--> McSQL actions.
>
> But when I attempt to show the DATE and q40 (comments) with the HTML code below,
> all I see on screen is: ] in the upper left corner.
You should probably be seeing a parse error...see below.
> URL: http://DakotaCom.net/~glomc/forms/Adj03.html (A poll on
> part-time faculty)
>
> Here's the code for the display that is not working...
> But the "]" may refer to earlier code in this long php file.
> I did not send the whole file, only the HTML part.
>
> /* Printing results in HTML */
>
>
> /* COMMENTED 2002-05-02
> print "<table>\n";
> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> print "\t<tr>\n";
> foreach ($line as $col_value) {
> print "\t\t<td>$col_value</td>\n";
> }
> print "\t</tr>\n";
> }
> print "</table>\n";
> */
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
> printf("
> <div class=\"colorfield\">
> <table>
> <tr><th>DATE</th><th>COMMENTS</th></tr>\n
>
> <tr><td>%s</td><td>%s</td></tr>
>
> </table>
>
> </div>
> <br />
> <br />\n",
> $row['added']);
> $row['q40']);
The ); closes the printf(), but the next line continues on to attempt
to add more arguments. You would either need to do this:
$row['added'],
$row['q40']);
...or, better yet, something like this, so you aren't printing out the
whole table for each row in the results:
echo "
<div class=\"colorfield\">
<table>
<tr><th>DATE</th><th>COMMENTS</th></tr>\n
";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "
<tr><td>{$row['time_stamp']}</td><td>{$row['heading']}</td></tr>\n";
}
echo "
</table>
</div>
";
Hope this helps,
Torben
> }
>
> /* Free resultset */
>
> mysql_free_result($result);
>
>
> /* Close the database connection */
>
> mysql_close($link);
>
> ?>
>
>
> </body>
> </html>
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----