PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Genteel Beaux
Forum Commoner
Posts: 28 Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama
Post
by Genteel Beaux » Fri Nov 22, 2002 9:48 am
How does one access an outside website using an hyperlink?
Here is my code:
Code: Select all
<?php
$conn = mysql_connect("localhost","","");
$query = "SELECT * FROM student";
$resultID = mysql_db_query("test_db", $query, $conn);
for ($x = 0; $x < mysql_num_rows($resultID); $x++)
{
$row = mysql_fetch_assoc($resultID);
print "<table><tr>";
print "<a href=" . $rowї'student_key'] . ">" . $rowї'student_class'] . " </a>";
print "</tr></table>";
}
?>
When I run it, I get this:
freshman
sophmore
junior
senior
graduate
Look fine except the I wanted to try to link to a website on the internet. Instead of getting
http//www.hotmail.com
I would get
http://127.0.0.1/http//www.hotmail.com
How does one link outside of the web server?
mydimension
Moderator
Posts: 531 Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:
Post
by mydimension » Fri Nov 22, 2002 10:00 am
what is the value of $row['student_key']
cybaf
Forum Commoner
Posts: 89 Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden
Post
by cybaf » Fri Nov 22, 2002 10:07 am
Just to check... was it just a typo when you wrote
http//www.hotmail.com ??
because if then... you missed out the ":" after http...
otherwise... like the above reply: need to know the value of the variable $row['student_key']
//cybaf
mydimension
Moderator
Posts: 531 Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:
Post
by mydimension » Fri Nov 22, 2002 11:18 am
it looks like the value you are putting into the databse is getting inserted incorrectly. may we see the code that inserts this value into the DB?
Genteel Beaux
Forum Commoner
Posts: 28 Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama
Post
by Genteel Beaux » Fri Nov 22, 2002 2:00 pm
There is no insert code. I plugged that data in manually.
Genteel Beaux
Forum Commoner
Posts: 28 Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama
Post
by Genteel Beaux » Sun Nov 24, 2002 8:42 am
When I do
print $row['student_key'];
I get
http://www.hotmail.com
But whenever I try to do a hyperlink, my web server's IP address is always in front. I don't know how to get rid of it when I try to access internet webpages from my pages.
Genteel Beaux
Forum Commoner
Posts: 28 Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama
Post
by Genteel Beaux » Sun Nov 24, 2002 9:09 am
Nevermind I found it on an another message board.
Instead of:
Code: Select all
<?php
print "<a href=" . $rowї'student_key'] . ">";
?>
I was suppose to use this:
Code: Select all
<?php
print "<a href="http://{$rowї'student_key']}">";
?>