By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,462 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,462 IT Pros & Developers. It's quick & easy.

href to link file

P: 13
Hi it's my first time to post something on the net.

Hope someone can help me with this.

I just started learning how to program with php (about a month ago), so pls. bear with me. So far, i've made a simple retrieval of my database (a list of names). With each name as a LINK to display the details of that name.

Expand|Select|Wrap|Line Numbers
  1. if (mysql_num_rows($result) > 0)
  2. {
  3.   while($row = mysql_fetch_row($result))
  4.   {
  5.     echo "<a href=dummy.php>$row[1]</a>",', '.$row[2].'<br/>';
  6.   }
  7. }
  8.  
[Please enclose your code within CODE tags. Thanks! --pbmods]

I used href to set the link on. Temporarily, i'm using a dummy.php file to link to when i click a name on the list. What i really wanted to happen was to display the full detail of that name when i click on one of the names.

I understand that the table (that has all the names and their details) is already open as i am already retrieving the names. I just want to be able to click on any of the names and display it's detail. I hope I didn't sound redundant just want my case to be understood better.

Can someone pls. show me how to do that?

Thanks,

LEARNING
May 17 '07 #1
Share this Question
Share on Google+
5 Replies


P: 12
Have you tried registering the primary key as a variable and linking to a query for the primary key which will return only one result?
then format the result you do not need to link externally this can all be done in the same script.
May 17 '07 #2

P: 13
Hi, thanks for your thought. I really appreciate it.

I'm not quite sure if i got what you mean but i'm gonna try it out. A short sample of code would really help me understand better cause i'm still new to this.

My other concern is that ... i understand that when i click on any of the names with the link it jumps to that linked file (in my case the dummy.php file). So, how do i know which record was clicked on so I can access the details of that name (or record)?

Upon clicking on any of the names (with links), how do i capture that name and bring it to the linked file (dummy.php) so i can use it there to access the details of that particular name or record?

Again,
LEARNING
May 17 '07 #3

P: 13
Have you tried registering the primary key as a variable and linking to a query for the primary key which will return only one result?
then format the result you do not need to link externally this can all be done in the same script.
Hi again thepresidentis,

Can you pls show me how to register a primary key as a variable and how to establish a link to a query for the primary key? Do you still use the href to do that? And yes, it's better if i do it in the same script.

A short sample code that illustrates what you mean will be greatly appreciated.

Please.

Thanks,
Learning
May 17 '07 #4

code green
Expert 100+
P: 1,726
Upon clicking on any of the names (with links), how do i capture that name and bring it to the linked file (dummy.php) so i can use it there to access the details of that particular name or record?
[PHP]$name = 'anybody';
echo '<a href="address/of/your/file/dummy.php?name=$name" </a>';

dummy.php
$namehere = $_GET['name'];
echo $namehere;

//result -- anybody
[/PHP]
May 17 '07 #5

P: 13
[PHP]$name = 'anybody';
echo '<a href="address/of/your/file/dummy.php?name=$name" </a>';

dummy.php
$namehere = $_GET['name'];
echo $namehere;

//result -- anybody
[/PHP]
Hi Code Green,

Thank you so much for helping me out. Now i know how it's done with href and passing on a value to the destination link file. Now i can proceed with my php programming lessons and eventually finish my very first website.

This is my first time to join a forum. And you know what i've found out?... Forums like this one really works.

[removed --pbmods]

LEARNING
May 17 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.