waverider Posted July 14, 2006 Share Posted July 14, 2006 Hello,I have a web page which draws product data from MySql and prints each product's information from an array in seperate tables created on the fly. Each iteration produces a new table with different product data. Each table has a link to a generic form which is activated through javascript in the link. Code for display of each table as below:[quote]echo <<<BLOCK </td> <td width="20%" height="20" align="left" valign="top" bgcolor="#444444"><div align="left"><strong><font color="#999900" size="2" face="Arial, Helvetica, sans-serif">{$story['make']}</font></strong></div></td> <td width="43%" height="20" align="left" valign="top" bgcolor="#444444"><strong><font color="#99CC00" size="2" face="Arial, Helvetica, sans-serif">{$story['model']}</font></strong></td> <td width="20%" height="20" align="left" valign="top" bgcolor="#444444"><strong><font color="#99ff00" size="3" face="Arial, Helvetica, sans-serif">{$story['price']}</font></strong></td> </tr> <tr> <td colspan="2" bgcolor="#444444"><font face="Arial, Helvetica, sans-serif">{$story['description']}</font></td> <td width="20%" align="center" bgcolor="#444444"><strong><font color="#ffcc00" size="5" face="Arial, Helvetica, sans-serif"> ?<br /> <strong><font color="#999900" size="1" face="Arial, Helvetica, sans-serif"><a href="javascript: newWindow('http://www.mysite.com/contact.php')">CLICK HERE</font></strong></td> </tr></table>BLOCK;[/quote]I would like to pass the data from [color=green]$story['description'][/color]through the URL to the form and print it on the form. How can I do this so that on each iteration stores the correct value of the variable for that particular product in the URL?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14544-placing-variables-in-a-link-on-the-fly/ Share on other sites More sharing options...
hitman6003 Posted July 14, 2006 Share Posted July 14, 2006 You really should use css and class declarations for all of your formatting rather than repeating the same stuff over and over...it makes it difficult to read.Anyway, what you want to do is:<a href="javascript: newWindow('http://www.mysite.com/contact.php?description={urlencode($story['description'])}')">Then on your contact.php page, use:echo urldecode($_GET['description']);Remember that there is a limit to how much data can be passed in the url, so if the descriptions are long, you may not be able to do this. Quote Link to comment https://forums.phpfreaks.com/topic/14544-placing-variables-in-a-link-on-the-fly/#findComment-57695 Share on other sites More sharing options...
waverider Posted July 14, 2006 Author Share Posted July 14, 2006 Thanks hitman6003,As soon as I put the code ?description={urlencode($story['description'])} into the link all I get is a blank page - remove the code again and things are back to normal ? I have checked that there are no extra spaces etc I have also tried with a number of small variables to remove size as an issue.And - yes- I must replace all that with css - next job . Quote Link to comment https://forums.phpfreaks.com/topic/14544-placing-variables-in-a-link-on-the-fly/#findComment-57742 Share on other sites More sharing options...
waverider Posted July 14, 2006 Author Share Posted July 14, 2006 It looks like I may have solved this. It appears that urlencode() doesn't like the form $story['description'] so I have placed the data in a standard variable and called this with ?description={urlencode($description)} which works great - thanks for the assistance Quote Link to comment https://forums.phpfreaks.com/topic/14544-placing-variables-in-a-link-on-the-fly/#findComment-57764 Share on other sites More sharing options...
waverider Posted July 14, 2006 Author Share Posted July 14, 2006 One more problem:When I call the variable from the form page using:[quote]<? urldecode($_GET['description']); echo $description;?>[/quote]I get [quote]{urlencode(my data here)}[/quote]What should I use to return just the data?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14544-placing-variables-in-a-link-on-the-fly/#findComment-57774 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.