Re: I am really stuck

From: Date: Fri, 24 Aug 2001 00:51:22 +0000
Subject: Re: I am really stuck
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11762@lists.php.net to get a copy of this message
"Matt C" <matthewcothier@hotmail.com> wrote in message news:LAW2-F136iSVvAyfxRy000013fd@hotmail.com... > 1) I would like to pull all entries out of a table that have dates that > haven't occured yet. Basically forget anything before the current day. How > do I do that? DELETE FROM table WHERE timestamp > $now > 2) I enter news into a table and would like to display a summary page. > Basically it has a list of headlines under the date they were added. > > Monday 10th August > *Item 1 > *Item 2 > > Tuesday 11th August > *Item 1 > > etc.... > > How do I do that? This is a wildly recurrent question, which really should be in the FAQ if it's not already (hint, hint...) Note: this is very PHP-like pseudocode; it WILL NOT run "as written". // The query MUST BE sorted by the listby field, // so that equal values will end up together. $query = "SELECT listbyfield, fieldB [, fieldC etc...] " ."FROM table ORDER BY listbyfield"; $res = mysql_query($query); $lastseen = ""; while ($row = mysql_fetch_array($res)) { // only echo the listby field if the value changes if ($row["listbyfield"] != $lastseen) { $lastseen = $row["listbyfield"]; printNewHeader($lastseen); } printEntry(); } ... you will of course have to define suitable stuff for printNewHeader() and printEntry().

« previous php.db (#11762) next »