# Solved: PHP & MySQL



## pcpro17 (Oct 9, 2006)

Hey, does anyone know how to adapt this code so that it will pull entries from a specific date range? Preferably, I would like it to pull info for just today. Is there a function for that?

```
$sql = "SELECT * FROM wp_posts";
$result = mysql_query($sql,$link) or die("Unable to select: ".mysql_error());
print "<table>\n";
while($row = mysql_fetch_row($result)) {
    print "<tr>\n";
    foreach($row as $field) {
        print "<td>$field</td>\n";
    }
    print "</tr>\n";
}
print "</table>\n";
```
Here are the fields available in the table:

post_author
 post_date 
 post_date_gmt 
 post_content 
 post_title 
 post_category 
 post_excerpt 
 post_status 
 comment_status 
 ping_status 
 post_password 
 post_name 
 to_ping 
 pinged 
 post_modified 
 post_modified_gmt 
 post_content_filtered 
 post_parent 
 guid 
 menu_order 
 post_type 
 post_mime_type 
 comment_count
Thanks!


----------



## brendandonhu (Jul 8, 2002)

Untested but this should work

```
$sql = sprintf('SELECT * FROM wp_posts WHERE post_date BETWEEN %s AND %s', strtotime('today'), strtotime('today') + 86400);
```


----------



## pcpro17 (Oct 9, 2006)

Thanks Brendan. I gave it a try. I'm not getting any errors, but it does not seem to be pulling any data in the query. Either that, or it's not printing the data. Any other suggestions?


----------



## pcpro17 (Oct 9, 2006)

Using Brendan's suggested modification and

```
print ($result);
```
 $result apperantly equals "Resource id #3". Does anyone know what this means?


----------



## cpscdave (Feb 25, 2004)

I could very easily be wrong but my experience with SQL is that DATE/DATETIME fields will not work if you pass into them unixtime stamps. 
*edit* I tried this out briefly and could not get the query to return correct results using a unix timestamp isntead of actual date *edit*

You actually have to convert them into the correct format.


```
$start = strftime("%Y-%M-%D 00:00:00", time()); //will give you todays date at 12:00:00am
$end_timestamp = strtotime("+1 DAY",time()); //will give you time stamp 1 day from now
$end = strftime("%Y-%M-%D 00:00:00", $end_timestamp); //will give you tomoorows date at 12:00:00am

$theQuery = "SELECT * FROM wp_posts WHERE post_date BETWEEN '{$START}' AND '{$END}' ";
```


----------



## brendandonhu (Jul 8, 2002)

That might be right, I'm not sure if post_date is a DATETIME or a Unix timestamp.


----------



## pcpro17 (Oct 9, 2006)

Thanks for the suggestion, Dave. A thought occured to me. It might be working (no errors), but the query range is off. I'm working from a dummy database right now, so how would I modify the query to pull everything in the last month (or two)? Thanks.


----------



## pcpro17 (Oct 9, 2006)

One more thought:
I checked the settings in the database, and it says that the default format for post_date is "0000-00-00 00:00:00". What is being generated is something like "2007-52-05/17/07 00:00:00". Are these formats the same?


----------



## cpscdave (Feb 25, 2004)

pcpro17 said:


> One more thought:
> I checked the settings in the database, and it says that the default format for post_date is "0000-00-00 00:00:00". What is being generated is something like "2007-52-05/17/07 00:00:00". Are these formats the same?


are you using the same formating string? 
to get something like 2007-52-05/25/07 00:00:00 your format string would look like

%Y-%U-%m/%D/%y (I think)

%Y-%m-%d 00:00:00 should give you 2007-05-16 00:00:00 (if today was May 16th 2007)

You can see all the formating elements at: 
http://ca3.php.net/strftime

Also if you are using a framework that breaks up the sql statement and recombines it be careful. The one we use had an issue where it would interpret BETWEEN <blah> AND <blah> wrongly and would recombine it wonkly.


----------



## pcpro17 (Oct 9, 2006)

Thanks for the suggestion, Dave! It's now pulling data from the MySQL database! But, this is only half the battle. Next, I need to get it to pull only certain data. Currently, it's pulling everything in the database in the given date rage. Here is what my code looks like now:

```
<?php
  include ("__db_open.php");

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime("%Y-%m-%d %H:%M:%S", $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime("%Y-%m-%d %H:%M:%S", $end_timestamp);

  $query = "SELECT * FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end'";

  $result = mysql_query($query,$link) or die("Unable to select: ".mysql_error());

  print "<table>\n";
  while($row = mysql_fetch_row($result)) {
    print "<tr>\n";
    foreach($row as $field) {
        print "<td>$field<br>$row</td>\n";
      }
    print "</tr>\n";
    }
  print "</table>\n";

  mysql_close($link);
?>
```
If you'd like to see what it's doing, go here:
http://www.correctnesscommentary.com/__test.php

Any suggestions on how to get it to pull data for only post_date, post_content, and post_title?

Thanks again!


----------



## cpscdave (Feb 25, 2004)

pcpro17 said:


> Any suggestions on how to get it to pull data for only post_date, post_content, and post_title?
> 
> Thanks again!


What version of MySQL are you using?? I dont belive BETWEEN worked correctly with dates till 4.3.x 
Also print out $query just before you send it to mysql it should look something like
SELECT * FROM wp_posts WHERE post_date BETWEEN '2007-04-16 15:41:37' AND '2007-05-17 15:41:37'

What format is post_date stored in the database? are they of type datetime? if they are a string or some other format this will not work  (and you should porbally convert the field to a datetime)

as far as only having the data base return specific fields change your query from:

SELECT * FROM table WHERE blah;

TO

SELECT field1, field2, field3 FROM table WHERE BLAH


----------



## pcpro17 (Oct 9, 2006)

Hello Dave. The MySQL client version is 5.0.16. I've attached a screen shot of the wp_posts table. I think it has the formatting info you requested.


----------



## pcpro17 (Oct 9, 2006)

Oh, if I'd built this database myself, I'd have no issue with changing the formats of stuff, but this database was generated by the WordPress setup, and because I'm planning on using the default WordPress interface to make updates, I don't want to do anything that might break it.


----------



## pcpro17 (Oct 9, 2006)

Oops, I also noticed a typo on my previous post. The code posted *does* pull data without any errors, but it's pulling everything within the date range. I just want it to pull only post_date, post_content, and post_title for now.


----------



## cpscdave (Feb 25, 2004)

Oh  that makes life a lot easier

Change

```
$query = "SELECT * FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end'";
```
TO


```
$query = "SELECT post_date, post_content, post_title  FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end'";
```


----------



## pcpro17 (Oct 9, 2006)

Ooohh! I see what it's doing now! ::smacks head:: I'll give that a try and let you know! :up:


----------



## pcpro17 (Oct 9, 2006)

Yup! It worked! Okay, now we're 70% of the way there!

Do you know how to get it to sort the query result in desending order so that the latest records will at the top (first) and the older records will be at the bottom (last)?


----------



## brendandonhu (Jul 8, 2002)

Add ORDER BY post_date DESC to your query.


----------



## cpscdave (Feb 25, 2004)

What brendan said 


```
$query = "SELECT post_date, post_content, post_title  FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
```
Just for refrence sake to sort the other oldest first use ASC


----------



## pcpro17 (Oct 9, 2006)

Thanks Dave! It worked great!  My code now looks like this:

```
<?php
  include ("__db_open.php");

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime("%Y-%m-%d %H:%M:%S", $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime("%Y-%m-%d %H:%M:%S", $end_timestamp);

  $query = "SELECT post_title, post_date, post_content FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";

  $result = mysql_query($query,$link) or die("Unable to select: ".mysql_error());

  print "<table>\n";
  while ($row = mysql_fetch_row($result)) {
    print "<tr>\n";
    foreach ($row as $field) {
      print "<td>$field</td>\n";
      }
    print "</tr>\n";
    }
  print "</table>\n";

  mysql_close($link);
?>
```
Do you have any suggestions on how I can recogise the time-stamp that is being pulled and/or how I can format it? I think I can figure out the formatting part, so I mainly just need help figuring out how to recognise it in the loop. Do you think it would be best if I setup a counter schema to keep track of where the loop is at? If you'd like to see what the code is generating, go here:
http://www.correctnesscommentary.com/__test.php


----------



## cpscdave (Feb 25, 2004)

I'm not sure what exactly you mean by "recognize" the timestamp. So forgive me if I tell you something that you already know/dont answer your question.

in your code after you fetch the result from sql and put it into to row you should actually have an array thats either 
[0]=>post_title (value) [post_title] => value
[1]=>post_date (value) OR [post_date] => value
[2]=>post_content (value) [post_content]=> value

*edit* I looked at php.net and it is first case

that being the case you'd probally want to have instead of 

```
foreach ($row as $field) {
      print "<td>$field</td>\n";
      }
```
Have something like (assuming first case from above)

```
print "<td>{$row[0]}</td>"; //print post title
print "<td>{$row[1]}</td>"; //print post date
print "<td>{$row[2]}</td>"; //print post content
```
That way you dont have to keep a counter in your loop, and that it's a fairly small array its not an issue just remembering that index 1 is the date.

As far is you want to reformat the date 

```
$date_stamp = strtotime($row[1]); //convert the formated date into a unix date stamp
$date = strftime("FORMAT STRING", $date_stamp;
```
You can see all the diff formatting options at http://ca.php.net/strftime

Hope that answers your question


----------



## pcpro17 (Oct 9, 2006)

Hello Dave! Thanks for the suggestion! I'm not really sure how the {} thing would work in my situation because I'm actually using divisions and not tables. Now's it's semi-working, I've moved the code over to the main page to get a better feel for what it's actually doing. Here's my code at this point:

```
include ("__db_open.php");

  $mysql_date_fmt  = "%Y-%m-%d %H:%M:%S";
  $entry_date_fmt  = "%A, %B %d, %G";
  $entry_time_fmt  = "%I:%M %p";

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime($mysql_date_fmt, $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime($mysql_date_fmt, $end_timestamp);

  $query = "SELECT post_date, post_title, post_content, ID FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
  $result = mysql_query($query,$link) or die("Unable to select: ".mysql_error());

  while ($record = mysql_fetch_row($result)) {
    $n = 0;
    foreach ($record as $field) {
//    $ping_status = $record[4];
//    if ($ping_status == "closed") { break; }
      $date = strtotime($record[0]); //convert the formated date into a unix date stamp
      switch ($n) {
        case 0:     // print entry date
          if ($date == $olddate) { break; }
          print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $date)."</h2>\n");
          $olddate = $date;
          break;
        case 1:     // print entry title
          print ("<div class=\"entries\">\n");
          print ("<h1  class=\"entries\">".$field."</h1>\n");
          print ("<h6  class=\"entries\">".strftime($entry_time_fmt, $date)."</h6>\n");
          break;
        case 2:     // print entry body
          print ("<p   class=\"entries\">".$field."</p>\n");
          print ("</div>\n");
          break;
        }
      $n++;
      }
    }

  mysql_close($link);
```
Do you have any ideas on how I can get the date (case 0) to only print once for each day? I thought I had it working, but somehow I broke it when I tried to use 'post_date_gmt'. eh. Also, you can see the two lines I have commented out. There is a deleted entry that keeps getting printed, so I'm trying to figure out how to screen out deleted entries from being printed. Any ideas?

Thanks. :up:


----------



## cpscdave (Feb 25, 2004)

SOrry for the bad formatting I had to email this to myself as for somereason my desktop will not stay logged in techguy... (think theres some setting wrong and its rejecting cookies.... *$!$!)

Neways probally the best thing to actually is to break up the query into 2. First one will pull out all the Y-M-D in the given period. Then inside a loop stepping thru that result will pull out all the posts for the day.

I have yet to figure out a way myself of getting around the whole "IS FIRST" flag issue.

Again I got rid of the loop FOREACH $result AS $field. As it really isnt nessecary.


```
$query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%y-%m-%d') FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
$result1 = mysql_query($query1,$link);

while($record1 = mysql_fetch_row($result1))
{
   $query = "SELECT post_date, post_title, post_content, ID FROM wp_posts WHERE post_date LIKE '{$record1[0]}%'  ORDER BY post_date DESC"; //will select all the posts that day
$result = mysql_query($query,$link);
 $first = true;
while ($record = mysql_fetch_row($result)) 
{
  if($first==true)
  {
    $first=false;
    print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $result[0])."</h2>\n");
  }
  print ("<div class=\"entries\">\n");
  print ("<h1  class=\"entries\">".$result[1]."</h1>\n");
  print ("<h6  class=\"entries\">".strftime($entry_time_fmt, $date)."</h6>\n");  
  print ("<p   class=\"entries\">".$result[2]."</p>\n");
  print ("</div>\n");
} //end while ($record = mysql_fetch_row($result)) {
}//end while($record1 = mysql_fetch_row($result1))
```
Also I see you used print("PRE".$var."POST"); This is fine but it is equivlant to PRINT("PRE{$VAR}POST");

The {} inside of "" is shorthand for ". ." (if that makes sense)


----------



## pcpro17 (Oct 9, 2006)

Hello Dave. Thanks for the suggestion, but something is really wrong. It's not pulling any of the correct data:

http://www.correctnesscommentary.com/__test.php

```
include ("__db_open.php");

  $mysql_date_fmt  = "%Y-%m-%d %H:%M:%S";
  $entry_date_fmt  = "%A, %B %d, %G";
  $entry_time_fmt  = "%I:%M %p";

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime($mysql_date_fmt, $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime($mysql_date_fmt, $end_timestamp);

  $query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%Y-%m-%d')) FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
  $result1 = mysql_query($query1,$link);

  while($record1 = mysql_fetch_row($result1)) {
    $query = "SELECT post_date, post_title, post_content, ID FROM wp_posts WHERE post_date LIKE '$record1[0]%' ORDER BY post_date DESC"; //will select all the posts that day
    $result = mysql_query($query,$link);
    $first = TRUE;
    while ($record = mysql_fetch_row($result)) {
      if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $result[0])."</h2>\n");
        }
      print ("<div class=\"entries\">\n");
      print ("<h1  class=\"entries\">".$result[1]."</h1>\n");
      print ("<h6  class=\"entries\">".strftime($entry_time_fmt, $date)."</h6>\n");  
      print ("<p   class=\"entries\">".$result[2]."</p>\n");
      print ("</div>\n");
    }
  }

  mysql_close($link);
```
Any other suggestions? Thanks.


----------



## cpscdave (Feb 25, 2004)

ummn ya I messed up hehehehe

The problem is. in:

While ($record = mysql_fetch_row($result))

I put for example print("....".*$result[0]*....);

it should be: 
print("....".*$record[0]*...)

sorry


----------



## pcpro17 (Oct 9, 2006)

Hi Dave. This is a lot better. Thanks!.  But, the dates are still really messed up:

http://www.correctnesscommentary.com/__test.php

Any other ideas?

Also, do you know what I would need to to differently to use 'post_date_gmt'? I'm assuming this is in reference to General Mountain Time, so it is as simple as correcting for the hour-offset?

Thanks!


----------



## cpscdave (Feb 25, 2004)

Did you change

```
if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $result[0])."</h2>\n");
        }
```
To


```
if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $record[0])."</h2>\n");
        }
```
OPPS I see in my last post I only had $record. (I keep hitting wrong button on here)

If you did make that switch put:


```
print_r($record);
exit;
if($first==true)
  {
    $first=false;
    print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $record[0])."</h2>\n");
  }
```
to see what exactly is being returned from the DB

-----------------------------------------------------------------------------------------
post_date_gmt would most likely be grenich_mean_time not mountian time.

So converting it to MST would be -8 and MDT would be -7 HOURS


----------



## pcpro17 (Oct 9, 2006)

Hello Dave. I tried printing the record, as you suggested above, but nothing is dumped. I just get this:

```
<html>
<head>
</head>
<body>
```
Any other ideas? Thanks.


----------



## cpscdave (Feb 25, 2004)

can you post the updated code again? 

It is really odd that nothing is being printed as before you had the other fields being displayed on the site and it was only the date that was messed up. 

Also if you could attach a dump of that tables schema I can test it locally


----------



## pcpro17 (Oct 9, 2006)

How do I dump the tables schema?


----------



## cpscdave (Feb 25, 2004)

open up a command prompt and type

mysqldump --user <YOUR USER> --password <IF YOU HAVE ONE> <DATABASE NAME> 

> bob.sql

eg

mysql --user root --password devPrestige contact > bob.sql

db is called devPrestige and table is contact.

should prompt you for a password (if you're using one)

Or you could install sqladministrator and create a backup from there.


----------



## pcpro17 (Oct 9, 2006)

Hi Dave. Thanks. Here is my current code and attached is the database dump:

```
<?php
  include ("__db_open.php");

  $mysql_date_fmt  = "%Y-%m-%d %H:%M:%S";
  $entry_date_fmt  = "%A, %B %d, %G";
  $entry_time_fmt  = "%I:%M %p";

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime($mysql_date_fmt, $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime($mysql_date_fmt, $end_timestamp);

  $query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%Y-%m-%d')) FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
  $result1 = mysql_query($query1,$link);

  while($record1 = mysql_fetch_row($result1)) {
    $query = "SELECT post_date, post_title, post_content, ID FROM wp_posts WHERE post_date LIKE '$record1[0]%' ORDER BY post_date DESC"; //will select all the posts that day
    $result = mysql_query($query,$link);
print_r($record);
exit;
    $first = TRUE;
    while ($record = mysql_fetch_row($result)) {
      if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"entries\">".strftime($entry_date_fmt, $record[0])."</h2>\n");
        }
      print ("<div class=\"entries\">\n");
      print ("<h1  class=\"entries\">".$record[1]."</h1>\n");
      print ("<h6  class=\"entries\">".strftime($entry_time_fmt, $record[0])."</h6>\n");  
      print ("<p   class=\"entries\">".$record[2]."</p>\n");
      print ("</div>\n");
    }
  }

  mysql_close($link);
?>
```


----------



## cpscdave (Feb 25, 2004)

Ahhh this works for me 

Change list:

Changed %G to %Y in date format. %Y works better
added strtotime around result[0] inside of strtotime. Strtottime expects a date stamp and sql returns the formated string. This is what was causing the bug

Why you couldnt print anything out with that print_r. It was in the wrong place  Hope this all works now


```
$mysql_date_fmt  = "%Y-%m-%d %H:%M:%S";
  $entry_date_fmt  = "%A, %B %d, %Y";
  $entry_time_fmt  = "%I:%M %p";

  $start_timestamp = strtotime ("-30 DAY", time());
  $start           = strftime($mysql_date_fmt, $start_timestamp);
  $end_timestamp   = strtotime ("+1 DAY",time());
  $end             = strftime($mysql_date_fmt, $end_timestamp);

  $query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%Y-%m-%d')) FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";

  $query1 = "SELECT * FROM wp_posts WHERE 1";

  $result1 = mysql_query($query1,$conn);


while($record1 = mysql_fetch_row($result1)) {
    $query = "SELECT post_date, post_title, post_content, ID FROM wp_posts WHERE post_date LIKE '$record1[0]%' ORDER BY post_date DESC"; //will select all the posts that day
    $result = mysql_query($query,$conn);

    $first = TRUE;
    while ($record = mysql_fetch_row($result)) {
     
      if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"entries\">".strftime($entry_date_fmt, strtotime($record[0]))."</h2>\n");
        }
      print ("<div class=\"entries\">\n");
      print ("<h1  class=\"entries\">".$record[1]."</h1>\n");
      print ("<h6  class=\"entries\">".strftime($entry_time_fmt, strtotime($record[0]))."</h6>\n");  
      print ("<p   class=\"entries\">".$record[2]."</p>\n");
      print ("</div>\n");
    }
  }

  mysql_close($conn);
```


----------



## pcpro17 (Oct 9, 2006)

Thanks for the update Dave! However, it's not pulling all the entries in the entire database. How do I change the second query so that it only pulls the range, like in the fist query? When I tried it started throwing all sorts of errors:

```
$query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%Y-%m-%d')) FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
  $query1 = "SELECT * FROM wp_posts WHERE 1";
  $result1 = mysql_query($query1,$link);

  while($record1 = mysql_fetch_row($result1)) {
    $query = "SELECT ID, post_date, post_title, post_content FROM wp_posts WHERE post_date LIKE '$record1[0]%' AND BETWEEN '$start' AND '$end' ORDER BY post_date DESC"; //will select all the posts that day
    $result = mysql_query($query,$link);
    $first = TRUE;
    while ($record = mysql_fetch_row($result)) {
      $new = strtotime (strftime ("%Y-%m-%d", strtotime($record[1])));
      if ($new != $date) {
        $first = TRUE;
        }
      if ($first == TRUE) {
        $first = FALSE;
        print ("<h2  class=\"content\">".strftime($entry_date_fmt, strtotime($record[1]))."</h2>\n");
        }
      print ("<div class=\"content\">\n");
      print ("<h1  class=\"content\">".$record[2]."</h1>\n");
      print ("<h6  class=\"content\">".strftime($entry_time_fmt, strtotime($record[1]))."</h6>\n");
      print ("<p>".$record[3]."</p>\n");
      print ("</div>\n");
      $date = strtotime (strftime ("%Y-%m-%d", strtotime($record[1])));
    }
  }
```
Thanks again!


----------



## cpscdave (Feb 25, 2004)

I'm not sure what you mean? 

The way this is set up is the first query is the range. It returns all the days within the range that have a post on them. 

Then as the code steps thru the first queries results 
The 2nd query returns all the posts from that specific day.

So you wouldnt want to add a range to the second query right?


----------



## pcpro17 (Oct 9, 2006)

Well, maybe the first query is not set up correctly then because it's pulling all of the entries from the database. I'll take another look at it.


----------



## pcpro17 (Oct 9, 2006)

Okay, I found the problem. There was an extra line in there that needed to be commented out. The entries query is now finished. Thanks for all your help, Dave!

```
$query1 = "SELECT DISTINCT(DATE_FORMAT(post_date, '%Y-%m-%d')) FROM wp_posts WHERE post_date BETWEEN '$start' AND '$end' ORDER BY post_date DESC";
//  $query1 = "SELECT * FROM wp_posts WHERE 1";
  $result1 = mysql_query($query1,$link);
```


----------



## cpscdave (Feb 25, 2004)

Doh! I left debug statements in... BAD Dave. 

hehehe if this was work I'd be buying lunch tommorow 

And I did that with another project to today... 

PM me if you need anymore help anytime!


----------

