Adding links inside php

Thread Solved

Join Date: Sep 2009
Posts: 12
Reputation: Kadjii is an unknown quantity at this point 
Solved Threads: 0
Kadjii Kadjii is offline Offline
Newbie Poster

Adding links inside php

 
0
  #1
Sep 25th, 2009
Hello, I'm having a strange problem. I'm trying to make a link to a page called stats.php for a series of first names that I have stored in a database. However, when I use the code below the hyperlink ends up being a link to the current page I'm on instead of to stats.php. Any help would be greatly appreciated.

..the following is in a while loop:
  1.  
  2. $fname=$row['fname'];
  3. echo "<td>";
  4. echo "<a href 'stats.php'>$fname</a>";
  5. echo "<td>";

Step 2 is that I want the page stats.php to display other stored info about the person, so I need to pass the person's name to to the next page when the link is clicked, and then be able to access the db with it, so if you have any helpful hints on how to do that, I'd appreciate that as well. Thanks!
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 525
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: Adding links inside php

 
0
  #2
Sep 25th, 2009
Take a look at this line:
  1. echo "<a href 'stats.php'>$fname</a>";

You are missing the = on href.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 25
Reputation: Rkeast is an unknown quantity at this point 
Solved Threads: 2
Rkeast Rkeast is offline Offline
Light Poster

Re: Adding links inside php

 
0
  #3
Sep 25th, 2009
Originally Posted by xan View Post
Take a look at this line:
  1. echo "<a href 'stats.php'>$fname</a>";

You are missing the = on href.
Also you might want to enclose your variable with curly brackets to avoid a possible parsing error like this:
  1. echo "<a href='stats.php'>{$fname}</a>";
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 12
Reputation: Kadjii is an unknown quantity at this point 
Solved Threads: 0
Kadjii Kadjii is offline Offline
Newbie Poster

Re: Adding links inside php

 
0
  #4
Sep 25th, 2009
Ah! Of course its something so basic that I forgot. Ah well, so goes it when you're a newbie programmer. Thanks a lot. Also, the suggestion for putting curly brackets around the variable will let me omit the first line where I had to convert the variable: $fname=$row['fname']; - and might actually solve a bigger chronic problem I've been having... so thanks for that too.

One last thing, I'm using the following line to send fname when the user clicks on it (using info I found on this site), but I can't figure out how to use it on the next page. I've been scanning the web for info so if I find the answer I'll report back...

  1. echo "<a href='stats.php?param={$row['fname']}'>{$row['fname']}</a>";
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,517
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: Adding links inside php

 
0
  #5
Sep 25th, 2009
To retrieve the variable param from the url simply use $_GET['param'] to get its value.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - MacGyver Fan
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 12
Reputation: Kadjii is an unknown quantity at this point 
Solved Threads: 0
Kadjii Kadjii is offline Offline
Newbie Poster

Re: Adding links inside php

 
0
  #6
Sep 25th, 2009
Awesome. Thanks.
Reply With Quote Quick reply to this message  
Reply

Tags
href, link, php

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for href, link, php
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC