ajetrumpet Posted October 7, 2010 Share Posted October 7, 2010 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 https://forums.phpfreaks.com/topic/215313-help-with-passing-a-variable-without-using-get/ Share on other sites More sharing options...
joel24 Posted October 7, 2010 Share Posted October 7, 2010 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 https://forums.phpfreaks.com/topic/215313-help-with-passing-a-variable-without-using-get/#findComment-1119679 Share on other sites More sharing options...
ajetrumpet Posted October 7, 2010 Author Share Posted October 7, 2010 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 https://forums.phpfreaks.com/topic/215313-help-with-passing-a-variable-without-using-get/#findComment-1119841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.