homepage Welcome to WebmasterWorld Guest from 54.204.77.26
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem passing variables in url
with $_GET[ ]
Sarah Atkinson




msg:1317104
 4:50 pm on May 11, 2005 (gmt 0)

how do you code a href with php verriables in it?
here are some ways I have tried

<a href="<?php echo "viewmenu.php?fromwhere=$fromwhere&xdate=$xdate&zdate=$zdate"?>">BACK</a>

echo ("<td><a href='editmenu.php?id=" . $id . '&fromwhere=' . $fromwhere . '&xdate=' . $x . '&zdate=' . $z . "'>Edit</a><br />");

 

KeywordROI




msg:1317105
 5:11 pm on May 11, 2005 (gmt 0)

What is the example url of this page?

Sarah Atkinson




msg:1317106
 5:28 pm on May 11, 2005 (gmt 0)

viewmenu.php?fromwhere=tablename&xdate=2005-05-1&zdate=2005-05-10

editmenu.php?id=5&fromwhere=tablename&xdate=2005-05-1&zdate=2005-05-10

kazecoder




msg:1317107
 10:33 am on May 12, 2005 (gmt 0)

Your url's look fine and the encode correctly. Lets see the code of the page that the variables are being passed to.

Sarah Atkinson




msg:1317108
 2:40 pm on May 12, 2005 (gmt 0)

I think i have all my code working. <knocks on partical board desk>.

But out of the two ways I posted are both legal and if so which is better?

mcibor




msg:1317109
 3:07 pm on May 12, 2005 (gmt 0)

Depends what you are doing. The second method is more complicated (you can make a mistake much easier), and the first meets the eye. However with the first method you can't put there any value from association array nor call a function. That means you can't write:

<a href="<?echo "viewmenu.php?fromwhere=$_POST['fromwhere']&date=date('Y-m-d')";?>
where with second way you may do it:
<a href="<?echo "viewmenu.php?fromwhere=".$_POST['fromwhere']."&date=".date('Y-m-d');?>

It's really up to you which method you use. I use both - when I can I use first, when it's not possible I use dots.

Hope this helps
Michal Cibor

kreeves




msg:1317110
 3:08 pm on May 12, 2005 (gmt 0)

I hate escaping in and out of PHP, so I like the latter.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved