943,712 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1491
  • PHP RSS
Nov 23rd, 2008
0

URL variables

Expand Post »
i need help in php
php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Narayan15 is offline Offline
20 posts
since Nov 2008
Nov 23rd, 2008
0

Re: URL variables

Use code tags.

Shouldn't
html Syntax (Toggle Plain Text)
  1. <a href="action.php?id='.$num.'">Text to be displayed</a>
be
html Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 975
Solved Threads: 140
Posting Virtuoso
scru is offline Offline
1,624 posts
since Feb 2007
Nov 23rd, 2008
0

Re: URL variables

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.
Reputation Points: 52
Solved Threads: 23
Posting Whiz in Training
martin5211 is offline Offline
271 posts
since Aug 2007
Nov 23rd, 2008
0

Re: URL variables

Great! its working. Thank you for ur help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Narayan15 is offline Offline
20 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Replace %20 characters in URL with a dash (-) | Code is from MySQL
Next Thread in PHP Forum Timeline: Php logic help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC