-
Notifications
You must be signed in to change notification settings - Fork 0
/
q_a.php
196 lines (190 loc) · 6.57 KB
/
q_a.php
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
<?php require_once('Connections/weblib.php'); ?>
<!DOCTYPE <html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>知识问答 | 大型主机科普网站</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>
<body>
<?php
//获取当前页数
if(isset($GET['page'])){
$page=intval($GET['page']);
}
else{
$page=1;
}
//每页数量
$pageSize=5;
mysql_select_db($database_weblib, $weblib);
$sql="select count(*) as amount from article where module = 4 and status=3";
$result=mysql_query($sql)or die(mysql_error());;
$num=mysql_fetch_array($result);
$amount=$num[0];
//获取页数
if($amount){
if($amount<$pageSize){$page_count=1;}
if($amount%$pageSize){
$page_count=(int)($amount/$pageSize)+1;
}else{
$page_count=$amount/$pageSize;
}
}else{
$page_count=0;
}
//获取数据
$pages=($page-1)*$pageSize;
if($amount){
$sql="select* from article where module = 4 and status=3 order by aid desc limit $pages,$pageSize";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
$rowset[]=$row;
}
}else{
$rowset=array();
}
?>
<div id="topBar">
<div class="wrapper">
<div class="l">
您好,欢迎访问大型主机科普网站!
</div>
<div class="r">
<a href="#" onclick="window.external.AddFavorite(location.href,'');">加入收藏</a>
<a href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(location.href);">设为首页</a>
<span> <a href="login.php" target="_blank">登录</a>| <a href="register.php" target="_blank">注册</a>| <a href="manager.html" target="_blank">管理员入口</a> </span>
</div>
</div>
</div>
<div id="header">
<div class="wrapper">
<div class="logo">
<a href="/"><img src="images/logo3.png" alt="大型主机科普网站" /></a>
</div>
</div>
</div>
<div id="nav">
<ul>
<li><a href="index.php" class="a1">首页</a></li>
<li><a href="recent.php" class="a2">科技快讯</a></li>
<li><a href="technology.php" class="a3">主机技术</a></li>
<li><a href="medias.php" class="a4">科普乐园</a></li>
<li><a href="q_a.php" class="a5">知识问答</a></li>
<form class="search" method="get" action="" target="_blank">
<p> <input class="searchTxt" value="" maxlength="30" name="wd" type="text" style="background-image:url('images/search_bg.png') " /> <input src="images/search_icon.png" class="search_icon" name="" type="image" /> </p>
</form>
</ul>
</div>
<script type="text/javascript">
function select_search_type(n){
document.getElementById('search_type1').className='';
document.getElementById('search_type2').className='';
document.getElementById('search_type3').className='';
document.getElementById('search_type'+n).className='current';
document.getElementById('search_type').value=n;
}
</script>
<div id="main">
<div id="page">
<div class="pageLeft">
<div id="qaMenu">
</div>
<div class="map2">
<a target="_blank" href="http://j.map.baidu.com/f_v1z" ><img src="images/ditu.png" /></a>
</div>
</div>
<div class="pageRight">
<div class="title_pic">
<img src="images/qa_pic.png" />
</div>
<div id="current">
所在位置:
<a href="" class="curr">首页</a> >
<a href="" class="curr">知识问答</a> >
<a href="" class="curr">主机技术</a>
</div>
<div id="qaTitle">
</div>
<div id="qaMain">
<?php
$record=($page-1)*$pageSize;
$records=5;
if($page==$page_count)
$records=$amount-(5*($page-1));
for($i=0;$i<$records;$i++){
?>
<div class="glist">
<div class="gimg">
<a href="articlebrowse.php?aid=<?php echo $rowset[$record]['aid']; ?>" target="_blank"><img src="<?php echo $rowset[$record]['pic']; ?> " height="93" width="145" /></a>
</div>
<div class="gtitle">
<p class="strong"><a href="articlebrowse.php?aid=<?php echo $rowset[$record]['aid']; ?>" target="_blank"><?php echo $rowset[$record]['title']; ?></a></p>
<p><?php echo $rowset[$record]['introduction']; ?></p>
</div>
</div>
<?php
$record++;
}
?>
</div>
<!-- 以下是来自明智科普网的分页js -->
<div class="itemC">
<script language="JavaScript"> <!--
function createPageHTML(_nPageCount, _nCurrIndex, _sPageName, _sPageExt){
if(_nPageCount == null || _nPageCount<=1){
return;
}
var nCurrIndex = _nCurrIndex || 0;
for(var i=0; i<_nPageCount; i++){
var sPageName = (i == 0 ? _sPageName : (_sPageName+"_" + i)) + "."+_sPageExt;
if(nCurrIndex == i){ document.write((i+1) + " ");
}else{ document.write("<a href='" + sPageName + "' class='current'>"+(i+1)+"</a> ");
}
}
}
//WCM置标
createPageHTML(0, 0, "index", "html");
</script>1
<a href="#" class="current">2</a>
<a href="#" class="current">3</a>
<a href="#" class="current">4</a>
<a href="#" class="current">5</a>
<a href="#" class="current">6</a>
<a href="#" class="current">7</a>
<a href="#" class="current">8</a>
<a href="#" class="current">9</a>
<a href="#" class="current">10</a>
</div>
<!-- 以上是来自明智科普网的分页js -->
</div>
<div class="clearit"></div>
</div>
</div>
<div id="footer">
<div class="nav">
<ul>
<li class="jianjie"><a href="#" class="a1">华工IBM中心简介</a></li>
<li><a href="#" class="a2">网站简介</a></li>
<li><a href="#" class="a3">联系我们</a></li>
<li><a href="message.php" class="a4">留言建议</a></li>
<li><a href="#" class="a5">友情链接</a></li>
</ul>
</div>
<!-- <div class="friendlink">
<ul>
<li><a href="#" class="a1">科学松鼠会</a></li>
<li><a href="#" class="a2">蝌蚪五线谱</a></li>
<li><a href="#" class="a3">中国科普网</a></li>
<li><a href="#" class="a4"></a></li>
</ul>
</div> -->
<!-- <div class="copyright">
<div class="l">© Copyright © 2014.</div>
</div> -->
</div>
<a href="#" title="返回顶部" id="goTop"></a>
</body>
</html>