Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-07-2009, 05:54 PM echo as a link/url
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
I need to make an echo into a url/link

Here is the code

PHP Code:
<?php
$con 
mysql_connect("*****","*****","*****");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("*****"$con);

$result mysql_query("SELECT * FROM Persons");


while(
$row mysql_fetch_array($result))
  {
  echo 
"<br>";
  echo 
"" $row['FirstName'] . "";
  echo 
"<br>";
  echo 
"" $row['LastName'] . "";
  echo 
"<br>";
  echo 
"" $row['LINK'] . "";
  echo 
"<br>";
  echo 
"" $row['AddedDate'] . "";
  echo 
"<br>";
  echo 
"******************************";
  }
echo 
"</table>";

mysql_close($con);
?>
See where it says
PHP Code:
  echo "" $row['LINK'] . ""
I need that to be a url, so can someone edit that echo so it will show as a url. And I can type in the url manually.
sith717 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-07-2009, 06:04 PM Re: echo as a link/url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
I need that to be a url
Then add the necessary HTML code to create a URL.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-07-2009, 06:06 PM Re: echo as a link/url
Super Talker

Posts: 115
Name: Not Telling
Trades: 0
I did, the page shows up blank...
sith717 is offline
Reply With Quote
View Public Profile
 
Old 08-07-2009, 06:41 PM Re: echo as a link/url
Junior Talker

Posts: 4
Trades: 0
You need it to look like this:
echo '<a href="' . $row['LINK'] . '">Name of the Link</a>';
immatt is offline
Reply With Quote
View Public Profile
 
Old 08-07-2009, 06:49 PM Re: echo as a link/url
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Assuming $row['LINK'] contains the url
PHP Code:
echo '<a href="' $row['LINK'] . '">Link Text</a>'
A couple unrelated things:

Why are you appending the empty string to your variables?
PHP Code:
echo "" $row['FirstName'] . ""
will function the same as:
PHP Code:
echo $row['FirstName']; 
There is a difference between single and double quotes. When a string is encased in double quotes it is parsed in order to determine if it contains any variables. This creates a small amount of unnecessary overhead if the string does not contain any variables. Normally you should use single quotes instead.
Ex.
PHP Code:
$name 'Matt';
echo 
"My name is $name"//will output My name is Matt
echo 'My name is $name'//will output My name is $name 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-07-2009, 06:53 PM Re: echo as a link/url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by sith717 View Post
I did, the page shows up blank...
Then show us the code you had for that
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-07-2009, 08:29 PM Re: echo as a link/url
Junior Talker

Posts: 2
Name: Kusnika reddeagoo
Trades: 0
Quote:
Originally Posted by sith717 View Post
I need to make an echo into a url/link

Here is the code

PHP Code:
<?php
$con 
mysql_connect("*****","*****","*****");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("*****"$con);

$result mysql_query("SELECT * FROM Persons");


while(
$row mysql_fetch_array($result))
  {
  echo 
"<br>";
  echo 
"" $row['FirstName'] . "";
  echo 
"<br>";
  echo 
"" $row['LastName'] . "";
  echo 
"<br>";
  echo 
"" $row['LINK'] . "";
  echo 
"<br>";
  echo 
"" $row['AddedDate'] . "";
  echo 
"<br>";
  echo 
"******************************";
  }
echo 
"</table>";

mysql_close($con);
?>
See where it says
PHP Code:
  echo "" $row['LINK'] . ""
I need that to be a url, so can someone edit that echo so it will show as a url. And I can type in the url manually.
In PHP you can put whatever HTML code in a php code, not only links... Ya it should be put HTML code and put $row['LINK'] inside the <?php ?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
chanidu87 is offline
Reply With Quote
View Public Profile
 
Old 08-08-2009, 12:53 AM Re: echo as a link/url
pdjprateek's Avatar
Experienced Talker

Posts: 38
Name: Prateek Jain
Location: India
Trades: 0
I think what you are looking for is this.


echo "<a href=\"http://www.google.com\">Name of the link</a>

OR

echo "<a href=\"$row['LINK']\">Name of the link</a>

Hope that helps.

the \" is used to echo " in php . because you cannot simply echo "

Prateek.
PDJSolutions.
__________________
I am a logo designer, doing logos at $20 . Mail me:
Please login or register to view this content. Registration is FREE
. for more details or if you want something to be done.
pdjprateek is offline
Reply With Quote
View Public Profile Visit pdjprateek's homepage!
 
Reply     « Reply to echo as a link/url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43534 seconds with 12 queries