Jump to content

Beginner Question: Adding hyperlink to array result


CagedApe

Recommended Posts

I'm trying to add a hyperlink to the results of an array I'm pulling. This is the code I have:

 

     $query=("SELECT * FROM members");
        $result=mysql_query($query);
        while($row = mysql_fetch_array($result)){
            echo $row['login'];
            echo "<br />" ;
        }  
        
?> 

 

How would I edit echo $row['login'] to display the result as a hyperlink?

 

Thanks in advance.

Link to comment
Share on other sites

You haven't really explained what $row['login'] holds, but a simple example would be.....

 

echo "<a href='page.php'>{$row['login']}</a>";

 

Thorpe is correct, you have not explained yourself. I assumed $row['login'] returned a username, as he assumed it returned a login URL. So if you can clarify this we can assist you better.

 

Link to comment
Share on other sites

You haven't really explained what $row['login'] holds, but a simple example would be.....

 

echo "<a href='page.php'>{$row['login']}</a>";

 

Sorry I guess i should have explained a bit better. $row['login'] returns a username. In any event that worked for me, thank you very much! I'm sure I'll be back to ask more questions, but for now thanks and good luck.

Link to comment
Share on other sites

You haven't really explained what $row['login'] holds, but a simple example would be.....

 

echo "<a href='page.php'>{$row['login']}</a>";

 

Sorry I guess i should have explained a bit better. $row['login'] returns a username. In any event that worked for me, thank you very much! I'm sure I'll be back to ask more questions, but for now thanks and good luck.

 

You can try this, but it sounds like you wanted something more like this:

echo "<a href=\"page.php?user=".$row['login']."&pass=".$row['pass']."\">Click here to login</a>";

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.