473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

I have query with anchor tag in php mysql?

If i click on city link give data order by city.same for username

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <p>
  5. <a href="searchorderby.php" >User Name</a> &nbsp;&nbsp;
  6.     <a href="searchorderby.php" >City</a>
  7. </p>
  8. <p></p>
  9. <table border="1">
  10. <tr>
  11. <td>userid</td>
  12. <td>usernmae</td>
  13. <td>userpassword</td>
  14. <td>address</td>
  15. <td>gender</td>
  16. <td>city</td>
  17. <td>Birthdate</td>
  18. </tr>
  19.  
  20. <?php 
  21. $link=mysql_connect("localhost","root","");
  22. mysql_select_db("login");
  23.  
  24. $queryfirst="SELECT * FROM userinfo ";
  25.  
  26. $result=mysql_query($queryfirst) or die(mysql_error());
  27.  
  28. while($row=mysql_fetch_array($result))
  29. {
  30. ?>
  31. <tr> 
  32. <td><?php echo $row['userid']; ?></td>
  33. <td><?php echo $row['username']; ?></td>
  34. <td><?php echo $row['userpassword']; ?></td>
  35. <td><?php echo $row['address']; ?></td>
  36. <td><?php echo $row['gender']; ?></td>
  37. <td><?php echo $row['city']; ?></td>
  38. <td><?php echo $row['Birthdate']; ?></td>
  39. </tr> 
  40. <?php 
  41. }
  42. ?>
  43.  
  44. </table>
  45. </body>
  46. </html>
  47.  
Dec 11 '10 #1
1 4115
johny10151981
1,059 1GB
you did nothing to be ordered as User name or as city name

here is a piece of suggested
Expand|Select|Wrap|Line Numbers
  1.  
  2. <a href="searchorderby.php?order=user" >User Name</a> 
  3. &nbsp;&nbsp;
  4. <a href="searchorderby.php?order=city" >City</a>
  5.  
  6. <?php
  7.  $link=mysql_connect("localhost","root","");
  8.  mysql_select_db("login");
  9.  
  10.  if(isset($_GET['order'])==false) 
  11.   $queryfirst="SELECT * FROM userinfo ";
  12.  else if($_GET['order']=='user')
  13.     $queryfirst="SELECT * FROM userinfo Order By UserName";
  14.     else if($_GET['order']=='city')
  15.     $queryfirst="SELECT * FROM userinfo Order By City";
  16.     else
  17. $queryfirst="SELECT * FROM userinfo ";
  18.  
  19. ?>
  20.  
  21.  
Dec 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jochem | last post by:
Hello, Lately I came accross this problem a couple of times, and I know there must be a clever solution. However, I did not find it untill now. When I add a entry to my mysql database from a...
1
by: Alexei Vladychevski | last post by:
i have 2 tables forumMsg forumTopic id idTopic Text idUser Views id Topic TopOrder -------------------------------------- ...
0
by: WhatsPHP | last post by:
Hi I have this MySql and PHP installed on the same machine. The Mysql general query log was started with mysqld --log, to log all the queries that will be received by the mysql server. This does...
4
by: svein.tjonndal | last post by:
I have the following query: select DATE_FORMAT(accountingdate,"%c") as month,sum(totalprice - freightcost - insurancecost - vat2 - vat3 - vat4) as totalprice from invoice where cancelled=0 and...
0
by: umangjaipuria | last post by:
I have two job queues doing complimentary work and writing their output once a minute into a file. The files for each minute have to processed in pairs - one from the first job queue and one from...
9
by: noor.rahman | last post by:
I was wondering how it may be possible to query 2 MySQL databases using one query statement from PHP. For instance: SELECT database1.tableA.field1 UNION database2.tableB.field2. My concern...
16
by: laverdir | last post by:
<? $query = "SELECT " . $this->tabela3 . ".id, " . $this->tabela3 . ".naziv, " . $this->tabela3 . ".spisatelj, " . $this->tabela3 . ".najava, " . " DATE_FORMAT(" . $this->tabela3 ....
1
by: danielbl | last post by:
I need of result below in different way Thanks any help! QUERY: SELECT t.`trafego_data`, u.`uf_sigla`, sum(t.`trafego_qtd`) as trafego_qtd
1
by: hridya | last post by:
I am new to hibernate can any one help me to make a hibernate query for ths mysql query select distinct hremployee1_.id as id8_1_ from hr_emp_attendance hrempatten0_ inner join ...
3
by: koti688 | last post by:
Hi Guys, I am a beginner to perl. I need a perl package which will perform basic DB operations like select , insert,update,delete operation MySql DB. i Have a Mysql DB which resides on my local...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.