ArizonaJohn Posted May 26, 2009 Share Posted May 26, 2009 Hello, I am trying to pass the variable "result" from page to page. I am trying to do it by making "result" a $_GET parameter and then appending it to the URL. Here is how "result" is created: $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") or die(mysql_error()); Then I make it into a $_GET parameter with this (I might be doing this wrong): $_GET['result'] = $result; Then I have all this pagination code which works great except that anything beyond the first page is blank. Here is an example of a URL link that I am trying to use to pass the variable "result" from page to page: echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&result={$_GET['result']}'>></a> "; The actual URL shows "?currentpage=2&result=Resource id #2" when I click on the ">" hyperlink. It should say "?currentpage=2&result=miami" if the user types in "miami." Any ideas on why this is not working? I think one possibility is that "result" is not the right variable for me to be passing through from page to page, but I'm not sure. Thanks, John Quote Link to comment https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/ Share on other sites More sharing options...
MadTechie Posted May 26, 2009 Share Posted May 26, 2009 Theirs no need to pass it to $_GET as that will have no effect, appending it to the URL is fine, Now the problem is your infact passing a resource, and not a string, because you haven't fetched form the database, as for the SQL statement, thats looking for a table ?.. inanycase it should look something like this <?php $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") or die(mysql_error()); $row=mysql_fetch_array($result); echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&result={$row[0]}'>></a> "; Quote Link to comment https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/#findComment-842766 Share on other sites More sharing options...
ArizonaJohn Posted May 26, 2009 Author Share Posted May 26, 2009 OK, thanks. I'm displaying my results as an HTML table, using mysql_fetch_row in a loop. What should I append to the URL in this case? My code is below. $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)){ 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)){ Quote Link to comment https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/#findComment-842773 Share on other sites More sharing options...
MadTechie Posted May 27, 2009 Share Posted May 27, 2009 i'm not sure what your asking.. Quote Link to comment https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/#findComment-842780 Share on other sites More sharing options...
ArizonaJohn Posted May 27, 2009 Author Share Posted May 27, 2009 I'm using the code below, and the ">" link still brings up a blank page. Also, the URL ends with "?currentpage=2&result= " and nothing else. So I'm not sure if I should be appending "{$table[0]}" to the end of my URL. echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1&result={$table[0]}'>></a> "; Quote Link to comment https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/#findComment-842781 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.