Page 1 of 1
PHP n00b question
Posted: Wed Apr 23, 2003 8:57 pm
by ph0rz
How do you get like
http://www.asdads.com/?force
to get the "force" part into something like
<a href=""force"">adad</a> so whenever I go to
http://www.asasa.com/?force
the link would show as <a href="force"> ? Thank you.
Posted: Wed Apr 23, 2003 11:11 pm
by m3mn0n
Code: Select all
<?php
$link = $_GET['force']; // passing along the variable from the url
echo '<a href="$link">This is a link to: $link</a>';
?>
...i think that's what you're asking.

Posted: Thu Apr 24, 2003 12:22 pm
by ph0rz
OMG thank you SO MUCH!
Posted: Thu Apr 24, 2003 12:43 pm
by ph0rz
I have one more question, how do I make like
http://www.blah.com/download.php?download.zip to show up as <a href="download.zip">asda</a> ? and also about that code you gave me, when I clicked on the link, it sent me to
http://www.blah.com/"$link/" . I am creating a download script for my website. Thanks for your help.
Posted: Thu Apr 24, 2003 3:19 pm
by twigletmac
PHP doesn't parse things in single quotes - you can try:
Code: Select all
echo '<a href="'.$link.'">This is a link to: '.$link.'</a>';
instead of
Code: Select all
echo '<a href="$link">This is a link to: $link</a>';
Mac
Posted: Thu Apr 24, 2003 3:27 pm
by ph0rz
Thanks, got it working.
Posted: Thu Apr 24, 2003 8:20 pm
by m3mn0n
Hmm yea whoops.

I should have used double quotes instead of single. So it can be,
Code: Select all
<?php
echo '<a href="'.$link.'">This is a link to: '.$link.'</a>';
?>
or
Code: Select all
<?php
echo "<a href="$link">This is a link to: $link</a>";
?>
I just like the second way more because it's so much less confusing to newbies when reading the code.
