ArizonaJohn Posted May 27, 2009 Share Posted May 27, 2009 Hello, Here is how my PHP works: a user types a word into an HTML form, which I label as a variable called "find." Then, I look in my MySQL database to find the table with the name that equals the variable "find," and turn this into an array called "table." I then print out the array called "table" in an HTML table. It all works great. Now I'm trying to add some pagination to it, and the pagination works great as well except for the part of passing the "table" array variable from page to page when I click on the pagination links beyond page one. Here is how I am displaying my results: $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") or die(mysql_error()); if(mysql_num_rows($result)>0){ while($table=mysql_fetch_row($result)){ $_GET['table'] = $table; print "<p class=\"topic\">$table[0]</p>\n"; $r=mysql_query("SELECT * , votes_up - votes_down AS effective_vote FROM `$table[0]` ORDER BY effective_vote DESC LIMIT $offset, $rowsperpage"); print "<table class=\"navbar\">\n"; while($row=mysql_fetch_array($r)){ Here is an example of a pagination link I am using: echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1&table={$_GET['table']}'><<</a> "; When I click on a pagination link, the end of the URL displays "?currentpage=2&table=Array". But it should display "?currentpage=2&table=miami" if the user types in "miami." So I guess my question is if there is some sort of special syntax that needs to be used when passing array variables from page to page when including them in URLs. Thanks, John Link to comment https://forums.phpfreaks.com/topic/159938-using-an-array-as-a-variable/ Share on other sites More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 i would use a seSSion on $_GET['table'] <?php session_start(); $_SESSION['table']=$_GET['table'] // and add the session to the link. // remember if you use session always use session_start(); at the top off every page needing sessions. Link to comment https://forums.phpfreaks.com/topic/159938-using-an-array-as-a-variable/#findComment-843525 Share on other sites More sharing options...
ArizonaJohn Posted May 27, 2009 Author Share Posted May 27, 2009 OK, thanks. So should I just add "&table={$_SESSION['table']}" to the end of the link? Link to comment https://forums.phpfreaks.com/topic/159938-using-an-array-as-a-variable/#findComment-843527 Share on other sites More sharing options...
ArizonaJohn Posted May 27, 2009 Author Share Posted May 27, 2009 Hi, I tried your suggestion, and the URL for the next pages still has "&table=Array" at the end of it, and the results are still blank. Any other ideas? Thanks, John Link to comment https://forums.phpfreaks.com/topic/159938-using-an-array-as-a-variable/#findComment-843564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.