I have an array of id's(array1) each with corresponding hits(array2). Im using an imploded array1 to select ids from a table. like so: select * from table where id in $array1; Now i want to add the corresponding hits of each id in the query result. The problem is that the result is automatically ordered by id ASC. So when i add my hits to the result, they do not match with the id's. How can i achieve this? Thanks in advance
I like the idea of using one array so its more organized ie array( id => value ); PHP: is a typical setup that I use. then you can loop through your results and find a match, sure this is slow but.. oh well foreach($result as $r) { foreach($hitArray as $h) { if($r['id'] == $h['id']) { // oh cool!, now $r is the row that has all your data and $h is your hit value } } PHP:
thanks a lot! But I forgot to add that i'm using paging: select * from table where id in $array1 $LIMIT; $LIMIT = $LIMIT($a,$b); I made it work without paging though..