Re: Sorting issue
| From: | Jeff | Date: | Fri, 08 Aug 2003 16:21:10 +0000 |
| Subject: | Re: Sorting issue | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29759@lists.php.net to get a copy of this message | ||
=P Sure!
Heres the List Records section...
function list_records() {
global $default_dbname, $gradient_tablename;
global $default_sort_order, $default_order_by, $records_per_page;
global $sort_order, $order_by, $cur_page;
global $PHP_SELF;
$link_id = db_connect($default_dbname);
if(!$link_id) error_message(sql_error());
$query = "SELECT count(*) FROM $gradient_tablename";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
$query_data = mysql_fetch_row($result);
$total_num_user = $query_data[0];
if(!$total_num_user) error_message('No Gradient Found!');
$page_num = $cur_page + 1;
$total_num_page = $last_page_num
= ceil($total_num_user/$records_per_page);
html_header();
echo "<CENTER><H3>$total_num_user Gradients found. Displaying the page
$page_num out of $last_page_num.</H3></CENTER>\n";
if(empty($order_by)) {
$order_by_str = "ORDER BY $default_order_by";
$order_by = $default_order_by;
}
else $order_by_str = "ORDER BY $order_by";
if(empty($sort_order)) {
$sort_order_str = $org_sort_order = $default_sort_order;
$sort_order = 'DESC';
}
else {
$sort_order_str = $org_sort_order = $sort_order;
if($sort_order == 'DESC') $sort_order = 'ASC';
else $sort_order = 'DESC';
}
if(empty($cur_page)) {
$cur_page = 0;
}
$limit_str = "LIMIT ". $cur_page * $records_per_page .
", $records_per_page";
$query = "SELECT kwo, lsd, date, event FROM $gradient_tablename
$order_by_str $sort_order_str $limit_str";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
?>
<DIV ALIGN="CENTER">
<TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">
<TR>
<TH WIDTH="24%" NOWRAP>
<A HREF="<?php echo
"$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=kwo";
?>">
Kodiak Work Order Number
</A>
</TH>
<TH WIDTH="24%" NOWRAP>
<A HREF="<?php echo
"$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=lsd";
?>">
LSD
</A>
</TH>
<TH WIDTH="24%" NOWRAP>
<A HREF="<?php echo
"$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=date";
?>">
Date
</A>
</TH>
<TH WIDTH="4%" NOWRAP>
<A HREF="<?php echo
"$PHP_SELF?action=list_records&sort_order=$sort_order&order_by=event";
?>">
Event
</A>
</TH>
<TH WIDTH="24%" NOWRAP>Action</TH>
</TR>
<?php
while($query_data = mysql_fetch_array($result)) {
$kwo = $query_data["kwo"];
$lsd = $query_data["lsd"];
$date = $query_data["date"];
$event = $query_data["event"];
echo "<TR>\n";
echo "<TD WIDTH=\"24%\"
ALIGN=\"CENTER\">$kwo</TD>\n";
echo "<TD WIDTH=\"24%\"
ALIGN=\"CENTER\">$lsd</TD>\n";
echo "<TD WIDTH=\"24%\"
ALIGN=\"CENTER\">$date</TD>\n";
echo "<TD WIDTH=\"4%\"
ALIGN=\"CENTER\">$event</TD>\n";
echo "<TD WIDTH=\"24%\" ALIGN=\"CENTER\">
<A
HREF=\"javascript:open_window('$PHP_SELF?action=view_record&lsd=$lsd');\">Vi
ew</A>
<A HREF=\"$PHP_SELF?action=delete_record&lsd=$lsd\"
onClick=\"return confirm('Are you
sure?');\">Delete</A></TD>\n";
echo "</TR>\n";
}
?>
</TABLE>
</DIV>
<?php
echo "<BR>\n";
echo "<STRONG><CENTER>";
if($page_num > 1) {
$prev_page = $cur_page - 1;
echo "<A
HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order&order_by=$or
der_by&cur_page=0\">[Top]</A>";
echo "<A
HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order&order_by=$or
der_by&cur_page=$prev_page\">[Prev]</A>";
}
if($page_num < $total_num_page) {
$next_page = $cur_page + 1;
$last_page = $total_num_page - 1;
echo "<A HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_ord
er&order_by=$order_by&cur_page=$next_page\">[Next]</A>";
echo "<A
HREF=\"$PHP_SELF?action=list_records&sort_order=$org_sort_order&order_by=$or
der_by&cur_page=$last_page\">[Bottom]</A>";
}
echo "</STRONG></CENTER>";
html_footer();
}
"Aaron Wolski" <aaronjw@martekbiz.com> wrote in message
news:005301c35dbc$7667e120$0203a8c0@AJW2...
> Seeing code might help us.
>
> Aaron
>
> > -----Original Message-----
> > From: Jeff [mailto:jroth1@telus.net]
> > Sent: August 8, 2003 10:44 AM
> > To: php-db@lists.php.net
> > Subject: [PHP-DB] Sorting issue
> >
> > Why would a mysql db think that 55 was greater than 14000.
> >
> > I have several headings that display sql data under them, when you
> click
> > on
> > the heading, it sorts that section (descending/ascending), but it only
> > seems
> > to be looking at the first two numbers in the one heading. Is there
> a
> > command that forces it to look at the entire record before sorting it?
> >
> > Thanks
> > Jeff
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>