Jump to content

Using an Array as a Variable


ArizonaJohn

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.