jwk811 Posted May 17, 2009 Share Posted May 17, 2009 $sql = "SELECT pd_id, c.cat_id, cat_name, pd_name, pd_thumbnail, pd_description FROM tbl_product p, tbl_category c WHERE p.cat_id = c.cat_id $sql2 AND user_id = '$userId' ORDER BY p.pd_date DESC"; $result = dbQuery(getPagingQuery($sql, $rowsPerPage)); $pagingLink = getPagingLink($sql, $rowsPerPage, $queryString); for some reason it wont order. is it bcuz im getting info from two tables? if so how can i make it work. or is it bcuz im making it into separate pages with the getpagingquery function? Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/ Share on other sites More sharing options...
Mchl Posted May 17, 2009 Share Posted May 17, 2009 What is this getPagingLink() function? Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-835978 Share on other sites More sharing options...
Ken2k7 Posted May 17, 2009 Share Posted May 17, 2009 What type is the column p.pd_date? Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-835979 Share on other sites More sharing options...
jwk811 Posted May 17, 2009 Author Share Posted May 17, 2009 What is this getPagingLink() function? function getPagingLink($sql, $itemPerPage = 10, $strGet = '') { $result = dbQuery($sql); $pagingLink = ''; $totalResults = dbNumRows($result); $totalPages = ceil($totalResults / $itemPerPage); // how many link pages to show $numLinks = 10; // create the paging links only if we have more than one page of results if ($totalPages > 1) { $self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ; if (isset($_GET['page']) && (int)$_GET['page'] > 0) { $pageNumber = (int)$_GET['page']; } else { $pageNumber = 1; } // print 'previous' link only if we're not // on page one if ($pageNumber > 1) { $page = $pageNumber - 1; if ($page > 1) { $prev = " <a href=\"$self?page=$page&$strGet\">[Prev]</a> "; } else { $prev = " <a href=\"$self?$strGet\">[Prev]</a> "; } $first = " <a href=\"$self?$strGet\">[First]</a> "; } else { $prev = ''; // we're on page one, don't show 'previous' link $first = ''; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNumber < $totalPages) { $page = $pageNumber + 1; $next = " <a href=\"$self?page=$page&$strGet\">[Next]</a> "; $last = " <a href=\"$self?page=$totalPages&$strGet\">[Last]</a> "; } else { $next = ''; // we're on the last page, don't show 'next' link $last = ''; // nor 'last page' link } $start = $pageNumber - ($pageNumber % $numLinks) + 1; $end = $start + $numLinks - 1; $end = min($totalPages, $end); $pagingLink = array(); for($page = $start; $page <= $end; $page++) { if ($page == $pageNumber) { $pagingLink[] = " $page "; // no need to create a link to current page } else { if ($page == 1) { $pagingLink[] = " <a href=\"$self?$strGet\">$page</a> "; } else { $pagingLink[] = " <a href=\"$self?page=$page&$strGet\">$page</a> "; } } } $pagingLink = implode(' | ', $pagingLink); // return the page navigation link $pagingLink = $first . $prev . $pagingLink . $next . $last; } return $pagingLink; } Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-835980 Share on other sites More sharing options...
jwk811 Posted May 17, 2009 Author Share Posted May 17, 2009 What type is the column p.pd_date? datetime and i also tried just pd_date that didnt work Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-835981 Share on other sites More sharing options...
jwk811 Posted May 17, 2009 Author Share Posted May 17, 2009 no one? Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836057 Share on other sites More sharing options...
PFMaBiSmAd Posted May 17, 2009 Share Posted May 17, 2009 for some reason it wont order What is it doing? What do you see in front of you? Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836067 Share on other sites More sharing options...
jwk811 Posted May 18, 2009 Author Share Posted May 18, 2009 its ordering by name Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836079 Share on other sites More sharing options...
jwk811 Posted May 18, 2009 Author Share Posted May 18, 2009 still dunno Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836645 Share on other sites More sharing options...
Ken2k7 Posted May 18, 2009 Share Posted May 18, 2009 Okay, can you run this for me - $sql = "SELECT pd_id, c.cat_id, cat_name, pd_name, pd_thumbnail, pd_description FROM tbl_product p, tbl_category c WHERE p.cat_id = c.cat_id $sql2 AND user_id = '$userId' ORDER BY p.pd_date DESC"; var_dumpp($sql); $result = dbQuery(getPagingQuery($sql, $rowsPerPage)); $pagingLink = getPagingLink($sql, $rowsPerPage, $queryString); Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836661 Share on other sites More sharing options...
jwk811 Posted May 18, 2009 Author Share Posted May 18, 2009 SORRY!!! im stupid. wrong file, hah wow thanks for your time guys Quote Link to comment https://forums.phpfreaks.com/topic/158513-solved-wont-order-by/#findComment-836669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.