steviez Posted December 15, 2009 Share Posted December 15, 2009 Hi, I am a complete PHP noob and am asking for help please I am working through a site to learn how to code in php and at every step learning how to do the work. The next step is a site search and I am stuck! My search function needs to take extra search criteria like height, weight, location, name etc and these will be text boxes and so on. I have my initial code and search functions set up but dont know how to pass these extra criteria to the search string if they exists. Here is my code so far: <?php /** set page name **/ $page = "search"; /** set page title **/ $page_title = "Search"; /** include header **/ include "header.php"; /** get task **/ $task = $misc->get_task(); /** get page **/ $p = $misc->get_page(); /** set empty vars **/ $browse_query = ""; /** set sorting variable **/ $sort = $misc->get_sort(); /** construct main query **/ $browse_query = "SELECT mm_users.user_id, mm_users.user_username, mm_users.user_photo, mm_users.user_signupdate, mm_users.user_lastlogindate, mm_users.user_dateupdated FROM mm_profiles LEFT JOIN mm_users ON mm_profiles.profile_id = mm_users.user_id WHERE mm_users.user_privacy_search = '1'"; /** get total users **/ $total_users = sql_num_rows($browse_query); /** make browse pages **/ $results_per_page = 20; if(($total_users % $results_per_page) != 0){ $maxpage = ($total_users) / $users_per_page + 1; }else{ $maxpage = ($total_users) / $users_per_page; } $maxpage = (int) $maxpage; if($p > $maxpage){ $p = $maxpage; } if($p < 1){ $p = 1; } $start = ($p - 1) * $results_per_page; /** add order and limit to query **/ $browse_query .= " ORDER BY $sort LIMIT $start, $results_per_page"; /** display users **/ $users = sql_query($browse_query); $user_array = array(); $user_count = 0; while($user_info = mysql_fetch_assoc($users)) { /** set new user **/ $search_user = new user(array($user_info['user_id'], $user_info['user_username'])); /** get users photo and see if it exists **/ $user_photo = $search_user->user_photo_crop("./assets/images/nophoto.gif"); /** set array of user info **/ $user_array[$user_count] = array('user_username' => $search_user->user_info['user_username'], 'user_photo' => $user_photo); $user_count++; } /** assign smarty variables **/ $smarty->assign('users', $user_array); $smarty->assign('total_users', $total_users); $smarty->assign('sort', $sort); $smarty->assign('maxpage', $maxpage); $smarty->assign('p', $p); $smarty->assign('p_start', $start+1); $smarty->assign('p_end', $start+$user_count); $smarty->assign('task', $task); /** include footer **/ include("footer.php"); ?> Please could anyone help me as i really want to learn and for me the best way is to be shown and to then do the work my self Thanks! Link to comment https://forums.phpfreaks.com/topic/185261-php-noob-search-help/ Share on other sites More sharing options...
steviez Posted December 15, 2009 Author Share Posted December 15, 2009 Anyone? been trying to do this all night Link to comment https://forums.phpfreaks.com/topic/185261-php-noob-search-help/#findComment-978078 Share on other sites More sharing options...
steviez Posted December 16, 2009 Author Share Posted December 16, 2009 I have managed to do this my self after much trial and error, thanks anyway. Link to comment https://forums.phpfreaks.com/topic/185261-php-noob-search-help/#findComment-978549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.