Languages :: PHP :: "IF" statement not making hyper link. Can someone help |
|||
| By: Senyonjo |
Date: 26/04/2003 00:00:00 |
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 | 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 | 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 | 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 | Type : Comment |
|
ping? |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








