flaab Posted February 25, 2007 Share Posted February 25, 2007 Hello 2all =) I'll go straigh to the point. I'm programming a little search engine for my site. The search function returns an array with the ID's of the databases retrievals for the users criteria. Example: $retrievals = array(2,56,57,190,257,346,...,whatever); And i want to split the results to view only 20 per page. So, i need to pass that array as a parameter for an url. Example: <a href="whatever.php?retrievals=<?php print $retrievals; ?> And let the array be received by another document. How can i do that? Is there a better way to do this? Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/ Share on other sites More sharing options...
Archadian Posted February 25, 2007 Share Posted February 25, 2007 you might just have to pass the array through the URL then break up the array on the desired script. Never heard of this before but its worth a try Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-193666 Share on other sites More sharing options...
flaab Posted February 25, 2007 Author Share Posted February 25, 2007 Nope...could you be a little more specific? =) U mean converting the array to string...and then joining it back? Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-193672 Share on other sites More sharing options...
flaab Posted February 25, 2007 Author Share Posted February 25, 2007 Solved. I pass a string made like this: $string = implode(",",$array); And then I explode it again. Thanks. Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-193683 Share on other sites More sharing options...
itsmeArry Posted February 27, 2007 Share Posted February 27, 2007 A better approach what I think would br serialize it and then unserialize it on next paga $strRetrievals = serialize($retrievals); <a href="whatever.php?retrievals=<?php print $strRetrievals; ?> and on next page you can use $strRetrievals = $_GET['retrievals']; $arrRetrievals = unserialize($strRetrievals); hope you find it useful for future use..... Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-195234 Share on other sites More sharing options...
boo_lolly Posted February 27, 2007 Share Posted February 27, 2007 actually, what you're talking about doing is called pagination, which is done an entirely different way... use the search tool on the forums. Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-195270 Share on other sites More sharing options...
magnetica Posted February 27, 2007 Share Posted February 27, 2007 If I understand correctly you are better doing for loop Google PHP for loops Link to comment https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/#findComment-195274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.