Repository navigation
Expand file tree
/
Copy pathview_topic.php
More file actions
222 lines (199 loc) · 7.6 KB
/
Copy pathview_topic.php
File metadata and controls
222 lines (199 loc) · 7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php include("header.php");
if($_GET['dis_id'])
{
$dis_id=$_GET['dis_id'];
}
$adjacents = 3;
$query = "SELECT COUNT(*) as num FROM tbl_answer where dis_id=".$_GET['dis_id'];
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];
//echo $total_pages;
$limit = 5; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0;
if ($page == 0) $page = 1;
//echo $pageno; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1;
//echo $lastpage; //last page minus 1
$sql48="select dis_id, dis_subject, created_by, created_date from tbl_discuss where dis_id=".$dis_id;
//echo $sql48;
$rs48=mysql_query($sql48);
$row48=mysql_fetch_array($rs48);
$sql49="select ans_id,dis_id,user_id,created_date, answer from tbl_answer where dis_id=".$dis_id." order by dis_id desc LIMIT $start, $limit";
//echo $sql49;
$rs49=mysql_query($sql49);
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$prev\">« </a>";
else
$pagination.= "<span class=\"disabled\">« </span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$counter\">$counter</a>";
}
$pagination .= "<span class=\"elipses\">...</span>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=1\">1</a>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=2\">2</a>";
$pagination .= "<span class=\"elipses\">...</span>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$counter\">$counter</a>";
}
$pagination .= "<span class=\"elipses\">...</span>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=1\">1</a>";
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=2\">2</a>";
$pagination .= "<span class=\"elipses\">...</span>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$counter\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"view_topic.php?dis_id=".$dis_id."&page=$next\"> »</a>";
else
$pagination.= "<span class=\"disabled\"> »</span>";
$pagination.= "</div>\n";
}
function humanTiming ($time)
{
$time = time() - $time; // to get the time since that moment
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}
?>
<style>
.panel-three a
{
color:#000;
text-decoration:none;
}
.panel-three a:hover
{
color:#B71A0F;
text-decoration:none;
}
</style>
<div class="internal-wrapper"><div style="padding:15px;margin-top:96px;border: 1px solid #CCCCCC;border-radius: 5px 5px 5px 5px;box-shadow: 1px 2px 2px #DADADA;">
<div class="red-color-heading-management top-heading-panel" style="width:980px;">Subject: <span class="black-color-heading"><?php echo $row48['dis_subject']?></span></div>
<div class="clear"></div>
<div class="panel-three top-heading-discuss" style="width:65px; float:left;margin-bottom:10px;">Pages: </div><div style="float:left;width:300px;"><?php echo $pagination?></div>
<div class="panel-three top-heading-discuss" style="width:170px; float:right;margin-bottom:10px;"><a href="post_answer.php?dis_id=<?php echo $dis_id?>">POST YOUR REPLY</a> </div>
<div class="clear"></div>
<div class="red-bar-discuss"><div class="box-one-discuss1 top-white-heading"><div class="padding-left15px">Sr. No.</div> </div>
<div class="box-two-discuss2 top-white-heading"><div class="padding-left15px">Comment By:-</div></div>
<div class="box-three-discuss3 top-white-heading" align="center">Comment</div>
<div class="box-four-discuss4 top-white-heading"><div class="padding-left15px">Posting On</div></div>
</div>
<div class="clear"></div>
<?php
$i=1;
while($row49=mysql_fetch_array($rs49))
{
$sql50="select user_id, user_firstname, user_lastname, facebook_id, account_image from tbl_user where user_id=".$row49['user_id'];
//echo $sql50;
$rs50=mysql_query($sql50);
$row50=mysql_fetch_array($rs50);
if($row50['facebook_id']=="")
{
if($row50['account_image']!='')
{
$srcf="uploads/".$row50['account_image'];
}
else
{
$srcf="images/red_img.png";
}
}
else
{
if($row50['account_image']!='')
{
$srcf="uploads/".$row50['account_image'];
}
else
{
$srcf="http://graph.facebook.com/".$row50['facebook_id']."/picture?width=60&height=60";
}
}
?>
<div class="box-one-discuss1 pink-back-left1">
<div class="padding-left15px box-internal-text2"><?php echo $i?></div>
</div>
<div class="box-two-discuss2 pink-back-left1">
<div class="padding-left15px"><div class="image-panel-discuss">
<img src="<?php echo $srcf?>" alt="#" class="image-border-new" style="height:60px;width:60px;"/>
</div>
<div class="content-panel-discuss box-internal2-text" style="margin-left:25px;font-size:18px;color:#000;font-family: 'CalibriRegular';line-height:45px;"><?php echo $row50['user_firstname']." ".$row50['user_lastname'] ?></div>
</div></div>
<div class="box-three-discuss3 pink-back-left1 box-internal-text" align="center"><?php echo $row49['answer']?></div>
<div class="box-four-discuss4 pink-back-left1"><div class="padding-left15px box-internal-text2"><?php echo humanTiming(strtotime($row49['created_date']))." ago"?></div>
</div>
<div class="clear"></div>
<?php
$i++;
}
?>
</div>
<?php include("footer.php");?>
</div>