banjax Posted November 12, 2008 Share Posted November 12, 2008 Hey everyone i just finished posting my table information using the fetch_array code i just need to know now how can i make it so other users can search and sort database entries by name age etc? Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/ Share on other sites More sharing options...
Maq Posted November 12, 2008 Share Posted November 12, 2008 1) Make a form with fields and pass the values to the query. 2) Use: ORDER BY *your_field* ASC; ORDER BY *your_field* DESC; If could show some code, elaborate, you know that sort of thing, maybe we could help you further. Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688485 Share on other sites More sharing options...
banjax Posted November 12, 2008 Author Share Posted November 12, 2008 what kind of code exactly? Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688500 Share on other sites More sharing options...
banjax Posted November 12, 2008 Author Share Posted November 12, 2008 ok i had no idea how or if i can edit my post but what i need basically is this http://www.phpfreaks.com/forums/index.php/topic,224589.0.html where users can search for other users by the first letter of there user name,Age,Position Etc www.FSAgency.net this is my site if you click on ad's you will see one database entry in there. that is where i need it to be able to search Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688547 Share on other sites More sharing options...
fenway Posted November 12, 2008 Share Posted November 12, 2008 what kind of code exactly? The query you're using to search. Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688662 Share on other sites More sharing options...
banjax Posted November 12, 2008 Author Share Posted November 12, 2008 i still have to make it but another question can i use fetch_array to get only a certain thing like usernames only starting with A or everyone only the age 18? Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688723 Share on other sites More sharing options...
Maq Posted November 12, 2008 Share Posted November 12, 2008 Yes, you can use a wildcard then order_by the field. For example if you want to grab the letter that was entered in the field by the user then you would probably do a post and put in in the query. Then you can have and ORDER BY clause. $letter = $_POST['user_letter_search']; $result = mysql_query("SELECT * FROM table_name WHERE name LIKE '{$letter}%' ORDER BY name ASC") or die(mysql_error()); If you want the user to toggle between ascending/descending then I would probably just make the "ASC" a variable. Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688729 Share on other sites More sharing options...
banjax Posted November 12, 2008 Author Share Posted November 12, 2008 still wont work sorry still kinda new at this maybe like a month or two how would a whole code look would it be long? Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688780 Share on other sites More sharing options...
Maq Posted November 12, 2008 Share Posted November 12, 2008 It depends. If you just want simple example with a field and a query, not very long. I already gave you the PHP/MySQL part now all you have to do is create a basic HTML form with an input field for the letter the user wants to search. Let me know if you need help, please provide code before asking for it. Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-688933 Share on other sites More sharing options...
fenway Posted November 13, 2008 Share Posted November 13, 2008 still wont work sorry still kinda new at this maybe like a month or two how would a whole code look would it be long? Please echo the sql query and post it here so that we can see why it doesn't work.... Quote Link to comment https://forums.phpfreaks.com/topic/132425-search-help/#findComment-689574 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.