pass a variable from one page to another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

Ok that makes sense. ty. Now i think i am getting somewhere. I can pull a '/tooltip.php?id=100' and actually see the data. Now i need to figure out why it's not displaying it in the tooltip. For some reason it does not like $_GET, cause it displays a blank tip.

Page 2

Code: Select all

if(isset($_GET['id']))
{
   $id = $_GET['id'];

$tooltip  = mysql_query("SELECT * FROM `". $my_result_table. "` WHERE `F_ID` = '$id'");


while($r = mysql_fetch_array($tooltip))
{
   $file   =   $r["F_FILENAME"];

   echo "Filename :". $file ."<BR>";
}
jammr
Forum Newbie
Posts: 16
Joined: Mon Jan 22, 2007 12:10 am

Post by jammr »

You didn't end your if statement in that chunk of code

Code: Select all

if(isset($_GET['id']))
{
   $id = $_GET['id'];

$tooltip  = mysql_query("SELECT * FROM `". $my_result_table. "` WHERE `F_ID` = '$id'");
}

while($r = mysql_fetch_array($tooltip))
{
   $file   =   $r["F_FILENAME"];

   echo "Filename :". $file ."<BR>";
}
I'd also add an else to make sure you don't get any errors.
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

Fixed. But still no go. I don't know what's the matter. I performed a

Code: Select all

var_export($_GET);
and it returned "array ( )" I just don't get it.

It's weird cause it displays fine when i view it from tooltip.php?id=31.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Please post your current version of
tarja311 wrote:Page 1 - pulling data in from my database

Code: Select all

while($r = mysql_fetch_array($sql))
{
	$id		=	$r["F_ID"];
	$file		=	$r["F_FILENAME"];

	echo "<TD><A HREF = '?w=result&cmd=filename&id=$id' onmouseover = ajax_showTooltip('tooltip.php',this);return false onmouseout=ajax_hideTooltip()>". $file ."</A></TD>";	
}
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

Here ya go.

Code: Select all

while($r = mysql_fetch_array($sql))
{
	$id	=	$r["F_ID"];
	$file	=	$r["F_FILENAME"];
		
	echo "<TD><A HREF = '?w=result&cmd=filename&id=$id'>". $file ."</A></TD>";	
	echo "<TD><A HREF = '#' onmouseover = ajax_showTooltip('tooltip.php?id=$id',this);return false onmouseout=ajax_hideTooltip()>". $details ."</A></TD>";
} // end while.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please try

Code: Select all

while($r = mysql_fetch_array($sql))
{
	$id	= $r["F_ID"];
	$file = $r["F_FILENAME"];
	
	$href = "?w=result&cmd=filename&id=$id";
	$tooltip = "?id=$id";
	
	echo "<TD><A HREF='" . $href. "'>". $file ."</A> (".$href.") </TD>";     
	echo "<TD><A HREF='#' onmouseover=ajax_showTooltip('tooltip.php'" . $tooltip . "',this);return false onmouseout=ajax_hideTooltip()>". $details ."</A>(".$tooltip.")</TD>";
} // end while.
and take a look at the newly printed values in (). Do they contain a valid id as expected?
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

Yes they do.

(?w=result&cmd=filename&id=31)

and

(?id=31)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And a var_export($_GET) in tooltip.php only shows array()? Sorry, I'm clueless then.
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

i appreciate your help though. :)
Mohamed
Forum Newbie
Posts: 21
Joined: Fri Jan 19, 2007 6:59 pm
Location: Seattle

Post by Mohamed »

which php version are you using?

have you tried $HTTP_POST_VARS
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Post by tarja311 »

PHP 5

Well i've found the problem. In the Ajax script i did not have FF support. I realized this after viewing it in IE, and it worked. :? I apologize for wasting everyones time. i really appreciate all the help. :)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

is it just me, or shouldn't that earlier code have been:

Code: Select all

$_SESSION[$id] = $file; // instead of $_SESSION['id'] = $id_file;
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

if it's ajax and tooltips ye be needing, check out jquery!
Post Reply