Can anyone help me with a problem?
I have data in a postgresql table which is a systems log book. I am creating a browser front end to this and have found that the fields that have carrage returns do not wrap at that point, ie the carrage return is ignored and the text fills the table row. When I use the psql command line utility and view the data, it displays correctly.
Any clues? Here's my code if that may help.
Many Thanks
Stephen
head>
<title> Results </title>
<meta name="author" content="STEPHEN HARRIS">
</head>
<hr WIDTH="100%">
<?php
$conn=pg_connect("host=localhost user=nobody dbname=logtests");
if (!$conn)
echo("<b> An Error Occured </b>");
$alt_headers=array("HOST","ITEM","ACTION");
// Execute Query
pg_Exec($conn,"SET DATESTYLE TO 'European';");
$result=pg_Exec($conn,"SELECT host, item, action FROM logs");
//Creation of the header of the table
echo("<center><p><font color=#FF0000 size=+2>These are the entities.</font></center>");
echo("<center><table BORDER=1 CELLPADDING=4 CELLSPACING=0 COLS=pg_numfields($result) NOSAVE>");
echo("<tr>");
for ($i=0;$i<sizeof($alt_headers);$i++) {
echo("<th align=center> <font size=+2> $alt_headers[$i] </font> </th>");
}
echo("</tr>");
$alternate = "2";
while ($row = pg_fetch_array ($result)) {
$field1 = $row["host"];
$field2 = $row["item"];
$field3 = $row["action"];
if ($alternate == "1") {
$color = "#CCFFCC";
$alternate = "2";
}
else {
$color = "#BFD8BC";
$alternate = "1";
}
echo "<tr bgcolor=$color><td>$field1</td><td>$field2</td><td>$field3</td></tr>";
}
echo "</table>";
?>
</body>
You may view it at :
http://tashtego.otago.ac.nz/logs/select5.php