Changeset 189
- Timestamp:
- 06/07/2003 11:19:42 PM (23 years ago)
- File:
-
- 1 edited
-
trunk/b2archives.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2archives.php
r99 r189 5 5 require_once('b2config.php'); 6 6 require_once($abspath.$b2inc.'/b2functions.php'); 7 8 dbconnect();9 7 10 8 // this is what will separate your archive links … … 53 51 54 52 if ($archive_mode == 'monthly') { 55 $arc_sql="SELECT DISTINCT YEAR(post_date) , MONTH(post_date)FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";53 $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC"; 56 54 $querycount++; 57 $arc_result =mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());58 while($arc_row = mysql_fetch_array($arc_result)) {59 $arc_year = $arc_row ['YEAR(post_date)'];60 $arc_month = $arc_row ['MONTH(post_date)'];55 $arc_results = $wpdb->get_results($arc_sql); 56 foreach ($arc_results as $arc_row) { 57 $arc_year = $arc_row->yr; 58 $arc_month = $arc_row->mn; 61 59 echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).'">'; 62 60 echo $month[zeroise($arc_month,2)].' '.$arc_year; … … 64 62 } 65 63 } elseif ($archive_mode == 'daily') { 66 $arc_sql="SELECT DISTINCT YEAR(post_date) , MONTH(post_date), DAYOFMONTH(post_date)FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";64 $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) as dom FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC"; 67 65 $querycount++; 68 $arc_result =mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());69 while($arc_row = mysql_fetch_array($arc_result)) {70 $arc_year = $arc_row ['YEAR(post_date)'];71 $arc_month = $arc_row ['MONTH(post_date)'];72 $arc_dayofmonth = $arc_row ['DAYOFMONTH(post_date)'];66 $arc_results = $wpdb->get_results($arc_sql); 67 foreach ($arc_results as $arc_row) { 68 $arc_year = $arc_row->yr; 69 $arc_month = $arc_row->mn; 70 $arc_dayofmonth = $arc_row->dom; 73 71 echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2).'">'; 74 72 echo mysql2date($archive_day_date_format, $arc_year.'-'.zeroise($arc_month,2).'-'.zeroise($arc_dayofmonth,2).' 00:00:00'); … … 79 77 $start_of_week = 1; 80 78 } 81 $arc_sql="SELECT DISTINCT YEAR(post_date) , MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date)FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";79 $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) AS dom, WEEK(post_date) AS wk FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC"; 82 80 $querycount++; 83 $arc_result =mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());81 $arc_results = $wpdb->get_results($arc_sql); 84 82 $arc_w_last = ''; 85 while($arc_row = mysql_fetch_array($arc_result)) {86 $arc_year = $arc_row ['YEAR(post_date)'];87 $arc_w = $arc_row ['WEEK(post_date)'];83 foreach ($arc_results as $arc_row) { 84 $arc_year = $arc_row->yr; 85 $arc_w = $arc_row->wk; 88 86 if ($arc_w != $arc_w_last) { 89 87 $arc_w_last = $arc_w; 90 $arc_ymd = $arc_year.'-'.zeroise($arc_row ['MONTH(post_date)'],2).'-' .zeroise($arc_row['DAYOFMONTH(post_date)'],2);88 $arc_ymd = $arc_year.'-'.zeroise($arc_row->mn,2).'-' .zeroise($arc_row->dom,2); 91 89 $arc_week = get_weekstartend($arc_ymd, $start_of_week); 92 90 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); … … 98 96 } 99 97 } elseif ($archive_mode == 'postbypost') { 100 $requestarc = " SELECT ID, post_date,post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0ORDER BY post_date DESC";98 $requestarc = " SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC"; 101 99 $querycount++; 102 $resultarc = mysql_query($requestarc);103 while($row=mysql_fetch_object($resultarc)) {100 $resultarc = $wpdb->get_results($requestarc); 101 foreach ($resultarc as $row) { 104 102 if ($row->post_date != '0000-00-00 00:00:00') { 105 103 echo "<li><a href=\"$archive_link_p".$row->ID.'">';
Note: See TracChangeset
for help on using the changeset viewer.