关于order by有关问题

WBOY
Release: 2016-06-13 11:19:43
Original
1127 people have browsed it

关于order by问题
类似这种的

比如说www.xxx.com/index.php?id=5&order=zhucetime

$order=$_GET['order'];
$id=$_GET['id'];


$sqltext="select * from table where n_pid='".$id."'  order by '".$order."'  asc";
 




如何实现第一次点击的时候是按asc排序   第二次点击后是按照desc排序 不断的循环切换啊?

如何实现第一次点击的时候是按asc排序   第二次点击后是按照desc排序 不断的循环切换啊?


------解决方案--------------------
<br />if(!isset($_SESSION['direction']) <br><font color='#FF8000'>------解决方案--------------------</font><br> $_SESSION['direction'] == 'desc')<br />{<br />   $_SESSION['direction'] = 'asc';<br />}<br />else<br />{<br />   $_SESSION['direction'] = 'desc';<br />}<br /><br />$sql = "select * from table where n_pid='".$id."'  order by  ".$order."  ".$_SESSION['direction'];<br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!