freecrm
New Member
- Messages
- 629
- Reaction score
- 0
- Points
- 0
php based...
I have a fairly simple sql query
SELECT blah de blah... ORDER BY X
I am trying to produce a dynamic table with column headers with a link back to the same page, but including
so that if the column header is clicked, the page refreshes, ordered by that column...
So I tried to set a variable with $_GET
The query is then:
So by default, it will order by COMPANY which works great.
If there is a value in the URL, it should pick it up
BUT.....
This is part of a mixed form/results page and when the link is clicked, it just refreshes the whole code, re-setting all the other variables.
How do I do this correctly?
I have a fairly simple sql query
SELECT blah de blah... ORDER BY X
I am trying to produce a dynamic table with column headers with a link back to the same page, but including
PHP:
?ordby=whatevercolumnisclicked
so that if the column header is clicked, the page refreshes, ordered by that column...
So I tried to set a variable with $_GET
PHP:
$varordby_RSOpps = "COMPANY";
if (isset($_GET['ordby'])) {
$varordby_RSOpps = $_GET['ordby'];
}
The query is then:
PHP:
$query_RSOpps = sprintf("SELECT CONTACTS.*, OPPS.* FROM CONTACTS INNER JOIN OPPS ON CONTACTS.CONTID=OPPS.OPCONTIDL WHERE CONTACTS.GROUPCODE LIKE %s AND OPPS.OPMANAGER LIKE %s AND OPPS.OPCOMPLETED LIKE %s ORDER BY %s DESC", GetSQLValueString($workgroup_RSOpps, "text"),GetSQLValueString("%" . $varmanager_RSOpps . "%", "text"),GetSQLValueString($varcompleted_RSOpps, "text"),GetSQLValueString($varordby_RSOpps, "text"));
So by default, it will order by COMPANY which works great.
If there is a value in the URL, it should pick it up
BUT.....
This is part of a mixed form/results page and when the link is clicked, it just refreshes the whole code, re-setting all the other variables.
How do I do this correctly?