图片调用 换行显示 及 添加链接

效果图:

代码:

<?php
    $connect = MYSQL_CONNECT( "localhost", "root", "") or die("Unable to connect to MySQL server");
    mysql_select_db("binary_data") or die("Unable to select database");
    $sql="select * from binary_data";
    $result=mysql_query($sql) or die(mysql_error());
    $count = 1;
   echo '<table width="80%" border="1" align="center" llpadding="1" bordercolor="#FFFFFF" bgcolor="#c17e50">';
while($out=@mysql_fetch_array($result))
{
        if($count%4 == 1)
        {
            echo '<tr>';
        }
        echo '<td width="25%"><table width="100%" height="100%" border="1" align="center" cellspacing="0" cellpadding="0">
      <tr>
        <td height="200" align="center" bgcolor="#FFFFFF"><a href=" '. $out["img_url"] . ' ">'."<img style='style:height:190px;width:190px;' src='get_data.php?id=".$out['id']."' onmouseover='see_big(".$out['id'].")' />".'</td>
      </tr>
      <tr>
          <td align=center>111</td>
      </tr>
      <tr>
          <td align=center>111</td>
      </tr>
    </table>
    </td>';
        if($count%4 == 0)
        {
        echo '</tr>';
        }
        $count +=1;
        if ($count%4 == 0)
  {
   echo "<br/>";
       $count = 0;
  }
 
}
echo '</table>';
?>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){

});
    function see_big(id)
    {
        var pic_id=id;
        $.ajax({
            type: "GET",
            data: "pic_id="+pic_id,
               url: "get_data.php",
            dataType:'text',
            success:function(data)
            {
                $("#big_pic img").attr("src","get_data.php?id="+data);
            }
        })
    }
</script>

 

posted @ 2013-11-30 11:03  果冻果冻我是西瓜  阅读(69)  评论(0)    收藏  举报