<a> Tag inside PHP</a>

时间:2014-11-12 07:34:53

标签: php html

我在php标签中使用了标签。当我运行代码时,它显示为链接。但它不能作为链接工作。这意味着链接不可点击。

$data1 = mysql_query("SELECT * FROM image_upload INNER JOIN user_table
 ON image_upload.user_id=user_table.user_id WHERE flag=1 ORDER BY timestamp DESC;") 
 or die(mysql_error());

//Puts it into an array

     while($info = mysql_fetch_array($data1)){
     //Outputs the image and other data 
      echo
'<div class="test" id='.$info['ID'].'>';
echo'<div class="username"><a href="profile.php" class="but but_t"      title="">'.$info['user_name'].'</a></div>';

  echo'<div class="imagedisplay"><img src="uploads/'.$info['image'].'" width="230px"     height=auto border="1px solid #"
-webkit-border-radius=" 20px"
-moz-border-radius= "20px"
border-radius="20px"  
  ></div>';
    echo'</div>';
    }
   ?>

我的css代码是

    div.test{
    margin: 5px;
    border: 1px solid #ffffff;
    border-radius:8px;
    height: auto;
    width:250px;
    float: left;
    text-align: center;
    background-color:#ffffff;

}

任何人都可以帮助我。

5 个答案:

答案 0 :(得分:3)

您忘记关闭第11行的标记

CODE

$data1 = mysql_query("SELECT * FROM image_upload INNER JOIN user_table
ON image_upload.user_id=user_table.user_id  WHERE flag=1 ORDER BY timestamp DESC; ")     or die(mysql_error());


//Puts it into an array

 while($info = mysql_fetch_array($data1)){
 //Outputs the image and other data 


echo '<div class="test" id='.$info['ID'].'>';
echo '<div class="username"><a href="profile.php" class="button" title="">'.$info['user_name'].'</a></div>';
echo '<div class="imagedisplay"><img src="uploads/'.$info['image'].'" style="width:230px; height:auto; border:1px solid #000; border-radius:20px;"></div>';
echo '</div>';

}
?>

答案 1 :(得分:0)

尝试以下

while($ info = mysql_fetch_array($ data1)){

echo " <div class=\"username\"><a href=\"profile.php\" class=\"button\" title=\"\">".$info['user_name']."</div>";

}

答案 2 :(得分:0)

这可能是由于您的报价安排。试试这个干净的版本:

<?php
    echo "<div class='username'>";
    echo "<a href='profile.php' class='button' title=''>$info['user_name']</a>";
    echo "</div>";
?>

答案 3 :(得分:0)

&#13;
&#13;
echo '<div class="username"><a href="profile.php" class="button" title="" target="_blank">'.$info['user_name'].'</a></div>';
&#13;
&#13;
&#13;

试试这个......

答案 4 :(得分:0)

链接应该正确关闭

'<div class="username">'.'<a href="profile.php" class="button" title="">'.$info['user_name'].'</a></div>'.
相关问题