SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | include 'bd/blocks/bd.php'; | |
3 | $result = mysqli_query($db,"SELECT keywords,description,author FROM page WHERE page='blog'"); | |
4 | $myrow = mysqli_fetch_array($result); | |
5 | - | if(isset($_GET['date']) && !empty($_GET['date'])){ |
5 | + | if(isset($_GET['date']) ){ //&& !empty($_GET['date']) |
6 | $date = $_GET['date']; | |
7 | } | |
8 | /* | |
9 | elseif (!isset($_GET['date']) && empty($_GET['date'])) { | |
10 | header("Location: index.php"); | |
11 | exit; | |
12 | }*/ | |
13 | else{ | |
14 | // header("Location: index.php"); | |
15 | echo("<script>location.href = 'index.php';</script>"); | |
16 | - | $date= "$date"; |
16 | + | |
17 | - | $dates=substr($date,0,7); |
17 | + | |
18 | - | $result2 = mysqli_query($db,"SELECT date FROM blog WHERE date='$dates' "); |
18 | + | //$date= "$date"; |
19 | - | $myrow2=mysqli_fetch_array($result2); |
19 | + | //$dates=substr($date,0,7); |
20 | $dates= date("Y-m", strtotime($date)); | |
21 | $sql="SELECT count(date) c FROM blog WHERE date='$dates' "; | |
22 | $sql="SELECT count(date) c FROM blog WHERE date like '{$dates}%' "; | |
23 | ||
24 | $result2 = mysqli_query($db,$sql); | |
25 | //since the data contain month-year.. you should use other name for this fieldname. | |
26 | ||
27 | $res=mysqli_fetch_array($result2); | |
28 | if($res['c']==0){ | |
29 | echo("<script>alert('no blog found'); location.href = 'index.php';</script>"); | |
30 | exit; | |
31 | } | |
32 | /* | |
33 | echo mysqli_num_rows($result2); | |
34 | if(mysqli_num_rows($result2)){ | |
35 | header("Location: index.php"); | |
36 | exit; | |
37 | } | |
38 | */ | |
39 | $date_title=$date; | |
40 | $date_begin =$date; | |
41 | $date++; | |
42 | $date_end=$date; | |
43 | $date_begin=$date_begin.'-00'; | |
44 | $date_end=$date_end.'-00'; | |
45 | ?> | |
46 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
47 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
48 | <head> | |
49 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
50 | <meta http-equiv="Content-Language" content="en" /> | |
51 | <meta name="description" content="<?php echo $myrow['description']; ?>" /> | |
52 | <meta name="keywords" content="<?php echo $myrow['keywords']; ?>" /> | |
53 | <meta name="author" content="<?php echo $myrow['author']; ?>" /> | |
54 | <title><?php echo 'archive for '. $date_title .'';?></title> | |
55 | <!-- HEADER --> | |
56 | <?php include 'bd/blocks/head.php'; ?> | |
57 | <!--ENDS HEADER --> | |
58 | </head> | |
59 | <body> | |
60 | <!-- WRAPPER --> | |
61 | <div id="wrapper"> | |
62 | ||
63 | - | $result = mysqli_query($db,"SELECT id,text,author,view,img,choose,title,date FROM blog WHERE date>'$date_begin' AND date<'$date_end' ORDER BY id DESC"); |
63 | + | |
64 | ||
65 | <!-- navigation & HEADER --> | |
66 | <?php include 'bd/blocks/header.php'; ?> | |
67 | <!-- ENDS navigation & HEADER--> | |
68 | <!-- MAIN --> | |
69 | <div id="main"> | |
70 | ||
71 | ||
72 | <!-- posts --> | |
73 | <div id="posts"> | |
74 | ||
75 | <!-- single-post --> | |
76 | <?php | |
77 | $sql="SELECT id,text,author,view,img,choose,title,date FROM blog WHERE date > '$date_begin' AND date < '$date_end' ORDER BY id DESC"; | |
78 | $result = mysqli_query($db,$sql); | |
79 | while($myrow = mysqli_fetch_array($result)){ | |
80 | $let55=explode(" ",$myrow["text"]); | |
81 | $me=0; | |
82 | $newtxt=""; | |
83 | while($me<55){ | |
84 | $newtxt.="".$let55[$me]." "; | |
85 | $me+=1; | |
86 | } | |
87 | printf(' | |
88 | <div class="post"> | |
89 | <p class="post-title custom">%s</p> | |
90 | <p class="post-meta">%s <span>by %s</span></p> | |
91 | <p class="post-comments custom">%s</p><br><br> | |
92 | <div class="%s-img"><a href="single.php?id=%s"><img src="%s" alt="" widht="610" height="230"/></a><span></span></div> | |
93 | <p class="brief">%s...</p> | |
94 | <p><a href="single.php?id=%s" class="more">More</a></p> | |
95 | </div>',$myrow["title"] , $myrow["date"] , $myrow["author"] ,$myrow["view"] ,$myrow["choose"] , $myrow["id"] , $myrow["img"] , $newtxt , $myrow["id"]);} | |
96 | ?> | |
97 | <!-- ENDS single-post --> | |
98 | ||
99 | <!-- blog-pager --> | |
100 | <ul class="blog-pager"> | |
101 | <li><a href="#">NEWER</a></li> | |
102 | <li><a href="#">OLDER</a></li> | |
103 | </ul> | |
104 | <!-- ENDS blog-pager --> | |
105 | ||
106 | ||
107 | ||
108 | </div> | |
109 | <!-- ENDS posts --> | |
110 | ||
111 | <!-- sidebar --> | |
112 | <?php include 'bd/blocks/side-block.php'; ?> | |
113 | <!-- ENDS sidebar --> | |
114 | ||
115 | ||
116 | </div> | |
117 | <!-- ENDS sidebar --> | |
118 | ||
119 | ||
120 | ||
121 | </div> | |
122 | <!-- ENDS MAIN --> | |
123 | ||
124 | </div> | |
125 | <!-- ENDS WRAPPER --> | |
126 | ||
127 | ||
128 | ||
129 | <!-- FOOTER --> | |
130 | <?php include 'bd/blocks/footer.php'; ?> | |
131 | <!-- ENDS FOOTER --> | |
132 | </body> | |
133 | </html> |