Jump to content

help with passing a variable without using GET


ajetrumpet

Recommended Posts

hello all,

 

I'm new here and I'm learning mysql/php.  Currently I have a dynamic table on one of my webpages, and the loop code looks like this:

while ($i < $numRows) {
$fname = mysql_result($result, $i, "fname");
$fcode = mysql_result($result, $i, "fcode");
$ftype = mysql_result($result, $i, "ftype");
$fdesc = mysql_result($result, $i, "fdesc"); ?>
  <tr>
	<td><a href="showfunction.php?fname=<?php echo "$fname"; ?>" target="_self"> <?php echo "$fname"; ?></a></td>
	<td> <?php echo "$fdesc"; ?> </td>
	<td><div align="center"> <?php echo "$ftype"; ?> </div></td>
  </tr>
<?php $i++; 
				  } ?>

what I would like to do is pass the ''fname'' variable to the "showfunction" page so it can printed from the database.  Here is the relevant portion of the page:

<body><div class="codeblock"> 
<div class="title">Code:<br /> 
</div><code><pre>

<?php echo $fcode; ?>

</pre></code></div>
<br /><pre><hr />
</pre>

I know that doesn't work, and I didn't expect it to because there is no way to 'get' the 'fname' variable from the preceeding script.  I do not want to use the GET method with this because from what I understand, you can only use it with Forms.  I really don't want to put controls in all of my table fields just to be able to pass the function name to the next page.  Does that make sense?

 

If I could get a jumpstart on this one last hurdle, I would appreciate it.  thank you so much!

 

Cheers.

Link to comment
Share on other sites

for GET you can point to the passed variables with

$_GET['variableName']; 
//in your example 
echo $_GET['fname'];

 

what exactly is fname... function name?

and what do you want to do with this value when you get it on the next page.

 

$_GET means that variables and data are sent via the url, i.e. www.mydomain.com/index.php?testVariable=Joels, then on index.php $_GET['testVariable'] would equal 'Joels'.

 

You'll want to use urlencode() and urldecode() to ensure unsafe URL characters are transformed into URL safe characters

 

Link to comment
Share on other sites

Hello Joel.  thank you for replying...

 

yes, 'fname' is the function name.  I was under the impression that GET was only used to get var's from form controls.  I guess I was wrong huh?  At any rate, I am going to try this and I will get back to you.  thanks!

 

I also will look at the encoding functions, thanks!

Link to comment
Share on other sites

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.