Hi all,
I want to use php variable for example $Lang[0] in the href as
<a href=$Lang[0] target=_blank>
where $Lang[0]="http://www.dailyhungama.com"
thanks in advance

Hi all,
I want to use php variable for example $Lang[0] in the href as
<a href=$Lang[0] target=_blank>
where $Lang[0]="http://www.dailyhungama.com"
thanks in advance

<a href="<?= $Lang[0] ?>" target="_blank">My Lang Link</a>

ok but my page is full php like

<?
$dbhost = 'xxxxxxxxxxx;
    $dbuser = 'xxxxxxxx';
    $dbpass = 'xxx';
    $dbname = 'xxxxx';
    $TABLE_NAME='xxxxx';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
    mysql_select_db($dbname, $conn) or die(mysql_error()); 
    $keyword=$_GET[key];
    $result = mysql_query("SELECT NewsPaper,Link,Lang FROM xxxx WHERE State LIKE '%$keyword%'",$conn);
    if (!$result) 
    {
            die('Query failed: ' . mysql_error());
    }

/* fetch rows in reverse order */
for ($i = 0; $i < mysql_num_rows($result); $i++) {
    if (!mysql_data_seek($result, $i)) {
        echo "Cannot seek to row $i: " . mysql_error() . "\n";
        continue;
    }

    if (!($row = mysql_fetch_assoc($result))) {
        continue;
    }


    $NewsPapers[]=$row['NewsPaper'];
    $Links[]=$row['Link'];

}
$nor=sizeof($NewsPapers);



for($j = 0; $j < mysql_num_rows($result); $j++)
{

    print "
    <tr>
        <td><a href=\"[B]".$Link[$j]."[/B]\" target=_blank> <img src=\"/images/news3.gif\" /> <font color=\"#FFFFFF\" size=3>".$NewsPapers[$j]."</font></a> </td>";
}


        ?>

help me in this

echo "<tr><td><a href='$Link[$j]' target='_blank'> <img src='/images/news3.gif' /> <font color='#FFFFFF' size='3'>$NewsPapers[$j]</font></a></td>";

the html is screwed up,
a mix of xhtml and html,
attributes are required to be quoted,
dtd is required
some browsers will fail to render on this type of error

wrape code in [code=language] [/code] tages where language is html php asp etc. to make viewing simpler

like the instructions on the top of the page tell you

commented: useful +5

if you want to use in side the html tag or href
use like this
<a href="<?php echo $Lnag[0] ?>"><?php echo $Lnag[0] ?></a>
this is the answer for you question.
if any dobut reply me.

commented: Do not use this code in your file, the poster has not bothered to read any part of your existing code and this generic crap will kill php at the first [icode]?>[/icode] +0

if you want to use in side the html tag or href
use like this
<a href="<?php echo $Lnag[0] ?>"><?php echo $Lnag[0] ?></a>
this is the answer for you question.
if any dobut reply me.

Do not use this code in your file, the poster has not bothered to read any part of your existing code and this generic crap will kill php at the first ?>

Looks like the other guys have allready answered this, But in case not:

$url = 'http://www.mysite.com'; // or $url = $lang[0];
$link = '<a href="'.$url.'" target="_blank">mylink</a>';
echo $link;

Thats the idea. you may need to modify slighty for your exact need but should do the trick.

Many thanks, Little Jon - that's very helpful

Miles

<a href="<?= $Lang[0] ?>" target="_blank">My Lang Link</a>

also

$url['google'] = "http://www.google.com";

echo "<a href=\"{$url['google']}\" target=\"_blank\">Link</a>";

thanks a ton "the wabbit".....ur code worked awesome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.