CagedApe Posted July 19, 2010 Share Posted July 19, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/ Share on other sites More sharing options...
Kevin.Arvixe Posted July 19, 2010 Share Posted July 19, 2010 This all depends on your application.... What value does $row['login'] return? If $row['login'] returns the users login, and your login page accepts GET parameters, you could do this: echo "http://www.domain.com/login?user=".$row['login']."&pass=".$row['pass']; Does that answer your question? Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/#findComment-1087932 Share on other sites More sharing options...
trq Posted July 19, 2010 Share Posted July 19, 2010 You haven't really explained what $row['login'] holds, but a simple example would be..... echo "<a href='page.php'>{$row['login']}</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/#findComment-1087934 Share on other sites More sharing options...
Kevin.Arvixe Posted July 19, 2010 Share Posted July 19, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/#findComment-1087936 Share on other sites More sharing options...
CagedApe Posted July 19, 2010 Author Share Posted July 19, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/#findComment-1087937 Share on other sites More sharing options...
Kevin.Arvixe Posted July 19, 2010 Share Posted July 19, 2010 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/208126-beginner-question-adding-hyperlink-to-array-result/#findComment-1087940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.