<?php 

        $query = "SELECT * FROM news ORDER BY id DESC";
        $result = pg_query($query);
        if (!$result) {
            echo "Problem with query " . $query . "<br />";
            echo pg_last_error();
            exit();
        }

        while($myrow = pg_fetch_assoc($result)) {
            printf ("<div class='article'><h1>%s</h1><p>%s</p><div class='sign'>%s GMT | %s", htmlspecialchars($myrow['subject']), $myrow['post'],htmlspecialchars($myrow['date']), htmlspecialchars($myrow['author']) );
			if ($logged) {
				printf (" | <a href='?a=newsadmin&amp;edit=" . $myrow['id'] . "'>edit</a>" );
			}
			printf ("</div></div>");
        }
?> 