visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: "IF" statement not making hyper link. Can someone help


By: Senyonjo U.S.A.  Date: 26/04/2003 00:00:00  English  Points: 300 Status: Answered
Quality : Excellent
<?php
$db_name = "aaaa";
$table_name = "xxxx";
$connection = @mysql_connect("mysql.co.uk", "pppp", "nnnn") or
die("could not establish a connection");
$db = mysql_select_db($db_name, $connection) or die("could not select the database");

$sql = "
select co_num,
co_name,
cty_num,
city
From xrates,biznames
Where
xrates.cust_num = biznames.cust_num
and
cty_num = \"$cty_num\" ";
$result = mysql_query($sql, $connection) or die("could not execute query");
if ($row = mysql_fetch_array($result))
//---------------------------------------------------------------
{
"<a href=\"http\\<A HREF="http://www.big.com\dev\$cty_num.php">www.big.com\dev\$cty_num.php</a>"></a>";
}
//--------------------------------------------------------------
?>
By: ThG Date: 26/04/2003 01:37:00 English  Type : Comment
some notes about your code:

if ($row = mysql_fetch_array($result))
//---------------------------------------------------------------
{
"<a href=\"http\\<A HREF="http://www.big.com\dev\$cty_num.php">www.big.com\dev\$cty_num.php</a>"></a>";
}
//--------------------------------------------------------------

this statement does absolutely nothing, and also there are some errors on the url syntax.

try with
{
print "<a href=\"<A HREF="http://www.big.com/dev/$cty_num.php\">http://www.big.com/dev/$cty_num.php\</a>">somelink</a>";
}

this anyway won't print anything related to the db query.. if you want to print for example the co_num field as link you would do:

{
print "<a href=\"<A HREF="http://www.big.com/dev/$cty_num.php\">http://www.big.com/dev/$cty_num.php\</a>">${row['co_num']}</a>";
}


By: VGR Date: 26/04/2003 02:02:00 English  Type : Answer
yes, to echo, you have to use generally PRINT or ECHO

Also, echo is very useful this way when you've a big block of HTML to output with some simple PHP variables in it (in stead of coding like <? echo $variable;?> or <?=$variable;?> :

echo <<<EOS
any HTML with $variable inside
as many lines a syou wish
EOS;
By: Epistemo Date: 29/04/2003 22:51:00 English  Type : Comment
Simple example of the print instance using a check cookie line:

<?php
if($HTTP_COOKIE_VARS["lala"] == "cookiename") {
print "hello mate - you have our cookie!";
} else {
print "hello mate - no cookie?";
}
?>

But echo is much more powerfull:

<?php
if($HTTP_COOKIE_VARS["lala"] == "cookiename") {
print "hello mate - you have our cookie!";
} else {
echo <<<END

hello mate - no cookie?

Whatever you want to type <b>here<b> ....... even PHP calls .... javascript .... anything goes....just test it ... use the echo to the fullest. hehehe

END;
}
?>

You still see that I'm using the print command in the first one ... I use the print when I have to display only 1 or two lines of text. Echo I use for larger blocks. It is easier to do things in echo since you can format it easier.


Maybe this helped?

By: ThG Date: 03/05/2003 12:15:00 English  Type : Comment

ping?


Do register to be able to answer

EContact
browser fav
page generated in 298.439980 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page