href to link file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learning
    New Member
    • May 2007
    • 13

    href to link file

    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.

    [code=php]
    if (mysql_num_rows ($result) > 0)
    {
    while($row = mysql_fetch_row ($result))
    {
    echo "<a href=dummy.php> $row[1]</a>",', '.$row[2].'<br/>';
    }
    }
    [/code]

    [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
    Last edited by pbmods; May 17 '07, 04:30 AM. Reason: Added code tags.
  • thepresidentis
    New Member
    • Feb 2007
    • 12

    #2
    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.

    Comment

    • learning
      New Member
      • May 2007
      • 13

      #3
      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

      Comment

      • learning
        New Member
        • May 2007
        • 13

        #4
        Originally posted by thepresidentis
        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

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          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]

          Comment

          • learning
            New Member
            • May 2007
            • 13

            #6
            Originally posted by code green
            [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
            Last edited by pbmods; May 17 '07, 11:05 PM. Reason: No religious content, please. Thanks!

            Comment

            Working...