URL variables

Reply

Join Date: Nov 2008
Posts: 20
Reputation: Narayan15 is an unknown quantity at this point 
Solved Threads: 0
Narayan15 Narayan15 is offline Offline
Newbie Poster

URL variables

 
0
  #1
Nov 23rd, 2008
i need help in php
  1. <?php
  2. $num=2;
  3. ?>
  4. <a href="action.php?id='.$num.'">Text to be displayed</a>

Here i m not getting $num value when i print echo $_GET['id'];
Last edited by peter_budo; Nov 24th, 2008 at 6:14 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,613
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 130
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: URL variables

 
0
  #2
Nov 23rd, 2008
Use code tags.

Shouldn't
  1. <a href="action.php?id='.$num.'">Text to be displayed</a>
be
  1. <a href="action.php?id=<?php echo $num; ?> ">Text to be displayed</a>
?

I ask because you appear to be concatenating $num outside of a PHP block.
Last edited by scru; Nov 23rd, 2008 at 10:19 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: URL variables

 
0
  #3
Nov 23rd, 2008
Always enclose PHP stuff into a PHP block. The code should be:

<a href="action.php?id=<?php echo $num; ?>">Text to be displayed</a>
or in this case printing a variable content:

<a href="action.php?id=<?=$num?>">Text to be displayed</a>
Ops. Scru and me the same response. You can use the last example too.
Last edited by peter_budo; Nov 24th, 2008 at 6:13 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 20
Reputation: Narayan15 is an unknown quantity at this point 
Solved Threads: 0
Narayan15 Narayan15 is offline Offline
Newbie Poster

Re: URL variables

 
0
  #4
Nov 23rd, 2008
Great! its working. Thank you for ur help
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC