![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hi, I have a simple search which is fine for now. Problem is when it is listing and sorting. For example It sorts as follows - A Guy Called Gerald A-ha A-ha Abigail Ace of Base Adamski Adeva Adrian Belew Aerosmith Agro I want it to ignore the the spaces and special charackters but not numerical numbers. From the above sort as you can see first three names should come after the 'Agro' What would I need to do and how? Thanks -----------Search Form --------------------------- <form action="preport.php?search=true" method="get" name="searchForm" id="searchForm"> Artist Search <input name="txtSearch" type="text" id="txtSearch3" size="10" maxlength="30"> <input type="submit" name="Submit" value="Search"> </form> ------------------------------- -----------search results --------------------- <?php $maxRows_rsReport = 20; $pageNum_rsReport = 0; if (isset($HTTP_GET_VARS['pageNum_rsReport'])) { $pageNum_rsReport = $HTTP_GET_VARS['pageNum_rsReport']; } $startRow_rsReport = $pageNum_rsReport * $maxRows_rsReport; $txtSearch_rsReport = "%"; if (isset($HTTP_GET_VARS['txtSearch'])) { $txtSearch_rsReport = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['txtSearch'] : addslashes($HTTP_GET_VARS['txtSearch']); } mysql_select_db($database_connMDB, $connMDB); $query_rsReport = sprintf("SELECT * FROM mdbTable WHERE AlbumArtist LIKE '%%%s%%' ORDER BY AlbumArtist+0, AlbumArtist ASC ", $txtSearch_rsReport); $query_limit_rsReport = sprintf("%s LIMIT %d, %d", $query_rsReport, $startRow_rsReport, $maxRows_rsReport); $rsReport = mysql_query($query_limit_rsReport, $connMDB) or die(mysql_error()); $row_rsReport = mysql_fetch_assoc($rsReport); if (isset($HTTP_GET_VARS['totalRows_rsReport'])) { $totalRows_rsReport = $HTTP_GET_VARS['totalRows_rsReport']; } else { $all_rsReport = mysql_query($query_rsReport); $totalRows_rsReport = mysql_num_rows($all_rsReport); } $totalPages_rsReport = ceil($totalRows_rsReport/$maxRows_rsReport)-1; ?> | |||
| Advertisements |
| | #2 | ||
| You must create a separate database-field that contains a sort-key. Usually this field is not displayed, but its contents are calculated from the visible field and stored. For example, "A ha," "A Ha", and "A-ha" {*great* band, by the way!!} would all be stored in a sort-key AHA. M.E. wrote: > I have a simple search which is fine for now. Problem is when it is > listing and sorting. > For example It sorts as follows - > A Guy Called Gerald > A-ha > A-ha > Abigail > Ace of Base > Adamski > Adeva > Adrian Belew > Aerosmith > Agro > > I want it to ignore the the spaces and special charackters but not > numerical numbers. From the above sort as you can see first three names > should come after the 'Agro' > > What would I need to do and how? > | |||
| | #3 | ||
| "M.E." <somewhere@downunder.com.au> schreef in bericht news:bj0u4l$qff$1@otis.netspace.net.au... > Hi, > > I have a simple search which is fine for now. Problem is when it is listing > and sorting. Not an answer to your question but perhaps you have to take a look at the possibilities of "full-text search" in MySQL. http://www.mysql.com/doc/en/Fulltext_Search.html Your search results can be ordered on relevance... RP | |||
| Featured Websites | ||||
|
![]() |
| Tags: help, php, search, sort |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sort order | Kurt Milligan | PHP | 2 | 07-01-2007 3:35 PM |
| How do I sort This array? | Karl McAuley | PHP | 1 | 07-01-2007 3:18 PM |
| Was going to come out this year! I was right with my prediction,sort of... | Phyber Quest | Console Subjects | 0 | 06-26-2007 12:07 PM |
| Does the PS3 have any sort of buzz about it being hot or a must have? | Penguin Commandos for Gore. | Computer Consoles | 14 | 05-30-2007 10:03 PM |
| Sort Gmail by different criteria | ~~Alan~~ | Google questions | 0 | 05-28-2007 1:45 AM |
| Featured Websites | ||||
|