?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?Re: Sorting columns
Author:??(---.cpe.net.cable.roger)
Date:???10-03-03 05:33

that will work fine...at the top of each column in you display page you have something like

Client

then in the myquerypage.php

//check to see if the variable is there
if (isset($_GET['sort'])){
$sort=$_GET['sort'];
}

//remember here to convert or use the column name...better to
//convert from a generic sort description and not give away
//table structure

//converting generic sort to table specific column names
//add more columns as needed
if ($sort=="client"){
$mysort = "order by client_name";
}elseif ($sort=="date"){
$mysort = "order by date_field_name";
}

//create query
$sql="select * from table_name [optional where clause]".$mysort;

$result=mysql_query($sql);

//echo out the results

?>

//you might want to also check out the sort features in php like
// natsort()...see http://ca3.php.net/manual/en/function.natsort.php

hth

?Topics Author? Date
?Sorting columns??new
Dean 10-03-03 04:21?
?Re: Sorting columns??new
bastien 10-03-03 05:33?
?Re: Sorting columns??new
Dean 10-03-03 06:16?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > that will work fine...at the top of each column in you > display page you have something like > > Client > > then in the myquerypage.php > > //check to see if the variable is there > if (isset($_GET['sort'])){ > $sort=$_GET['sort']; > } > > //remember here to convert or use the column name...better to > //convert from a generic sort description and not give away > //table structure > > //converting generic sort to table specific column names > //add more columns as needed > if ($sort=="client"){ > $mysort = "order by client_name"; > }elseif ($sort=="date"){ > $mysort = "order by date_field_name"; > } > > //create query > $sql="select * from table_name [optional where > clause]".$mysort; > > $result=mysql_query($sql); > > //echo out the results > > ?> > > //you might want to also check out the sort features in php > like > // natsort()...see > http://ca3.php.net/manual/en/function.natsort.php > > hth ">??

Provided By
Phorum