Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/159786-passing-a-variable-from-page-to-page/
Share on other sites

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> "; 

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)){

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> "; 

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.