<;a>;PHP内部的标记


<a> Tag inside PHP

我在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;

}

有人能帮我吗?

您忘记关闭第11行上的标签

代码

$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>';
}
?>

尝试以下

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

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

}

这可能是由于引号的排列。试试这个干净的版本:

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

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

试试这个。。。

链接应正确关闭

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