adam291086 Posted March 22, 2009 Share Posted March 22, 2009 Hello, i have an array like the one below Array ( [skill 1] => 1 [Education 2] => 17 [Education 3] => 1 [job 4] => 1 [EmploymentLevel 5] => 17 [EmploymentLevel 6] => 1 [ProQualificaition 7] => 1 [sector 8] => 1 ) The value of each section within the array equals a user id. What i want to do is look at all the values and count how many times a user appears in the above query for example user 1 appears 5 time and user 17 appears 2 times. I then want to display the users information in order of occurrence in the array for example user 1 above user 17. Can someone push me in the right direction. I am an able coder but have no idea how to go about this. Quote Link to comment Share on other sites More sharing options...
.josh Posted March 22, 2009 Share Posted March 22, 2009 array_count_values arsort Quote Link to comment Share on other sites More sharing options...
adam291086 Posted March 22, 2009 Author Share Posted March 22, 2009 Thanks, thats sort me out! Quote Link to comment Share on other sites More sharing options...
adam291086 Posted March 22, 2009 Author Share Posted March 22, 2009 I have solved the above problem but i now has another array question. i Have the following code foreach (array_keys($search) as $key) { $data = $db->get_results("SELECT * FROM persons WHERE idUser = '".$key."'",ARRAY_A); print_r($data); } this generates two arrays full of database information. I want to display one lot of information and have a button to view the second bit of information, something like pagination but with multiple arrays. Is this possible, if so how? Quote Link to comment Share on other sites More sharing options...
adam291086 Posted March 22, 2009 Author Share Posted March 22, 2009 anyone? Quote Link to comment Share on other sites More sharing options...
.josh Posted March 22, 2009 Share Posted March 22, 2009 okay if I read/understood that right, it sounds like you are grabbing more than one page worth of info from the db and want to paginate it. The point of pagination is that you only grab one page worth of data at a time. Think maybe you need to back up a few steps in your process and rethink the whole pulling stuff out of the db thing. Or else, you need to be a bit more specific. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted March 22, 2009 Author Share Posted March 22, 2009 I am making a simple search interface that searches multiple database tables. Within the tables it looks for the users id which is a foreign key. It then does some simple stuff with the array i.e count the number of times a user appears. I then search the database for each user within that array. In this case there is two, some times there could be three or more. Therefore i want a way to only show each arrays information at a time. The once the user clicks next it shows the next array info. For example Array ( [idUser] => 2 ) Array ( [idUser] => 4 ) so when the page first load is shows the idUser 2 info and then on a button click shows idUser 4 info Quote Link to comment Share on other sites More sharing options...
adam291086 Posted March 23, 2009 Author Share Posted March 23, 2009 ok i now have this foreach (array_keys($search) as $key) { $data = $db->get_results("SELECT * FROM persons WHERE idUser = '".$key."'",ARRAY_A); $pagination[$i] = $data; $i = $i + 1; } $resultID = 1; $nextID = $resultID + 1; echo '<a href="search.php?id='.$nextID.'">next</a>'; echo $_GET['id']; if (isset($_GET['id'])) { $resultID = $_GET['id']; $nextID = $_GET['id'] + 1; echo '<pre>'; print_r($pagination[$resultID]); echo '</pre>'; } else { echo '<pre>'; print_r($pagination[$resultID]); echo '</pre>'; } it shows the first lot of array data but when i click next nothing is displayed when i know there should be Quote Link to comment 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.