如何从列表中获取图像?

时间:2015-10-31 05:14:28

标签: php mysql

我的数据库中有“tag”和“kategori”列表

搜索后,有一个“tag”,“kategori”和“imageId”列表作为打开显示数据库图像的新页面的链接

这是来自listing.php的代码

<?php
$conn = mysql_connect("localhost", "denis", "denis");

mysql_select_db("company");
//echo($_POST["tag"]);
if(isset ($_POST['tag']))
    {


        $atags = explode(" ",$_POST['tag']);
        $mytags = " ";
        foreach($atags as $tag)
        {
            if($tag!= "")
            {
                $mytags = $mytags." tag like '%". $tag . "%' or kategori like '%". $tag . "%' or" ;

            }

        }
        echo $mytags;
    $mytags = substr($mytags,1,strlen($mytags)-3);
    $sql2="select tag,kategori,imageId from output_images where tag LIKE '%".$_POST['tag']."%' and ".$mytags."order by imageId asc";
    //$sql="SELECT tag,kategori FROM output_images WHERE tag LIKE '%".$_POST['tag']."%' or kategori LIKE '%".$_POST['tag']."%'";
    $result=mysql_query($sql2);
    }
?>
<html>
<head>
<title>Listing Database</title>
</head>
<body>
<form method="POST" >

<input type="text" name="tag" value=" ">
<input type="submit" name="search" value="Cari"/>
</form>

<table width="600" border ="1" cellpadding="1" cellspacing="1">
<tr>


<th>Tag</th>
<th>Kategori</th>
<th>Gambar</th>
<tr>
<?php
echo mysql_num_rows($result);
if(mysql_num_rows($result)!=0)
{
    while($row=mysql_fetch_array($result))
    {
        echo "<tr><td>".$row["tag"]."</td><td>".$row["kategori"]."</td><td><a href=show.php?idtag=".$row["imageId"].">Gambar</a></td></tr>";

    }
}else
    {
        echo "No Result Found";
    }
?>
</table>

</body>
</html>

这是我的show.php,它显示了图片

<html>
<body>
<?php
$conn = mysql_connect("localhost", "denis", "denis");

mysql_select_db("company");


?>
<form method="POST" >
<a href="buku.php?id=<?php echo $prev['imageId']; ?>">Prev<a/>
<a href="buku.php?id=<?php echo $next['imageId']; ?>">Next<a/>
</form>


<?php   

    $res2=mysql_query($sql2,$conn);
    while($row2=mysql_fetch_array($res2))
    {
        echo("<img src='http://"  . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/profile.php?image_id=". $row2["imageId"]. "' width='15%' height='30%'/>"); 

    }


    mysql_close();
    echo("ada");
mysql_close($conn);

?>
</body>
</html>

我的问题是,图片不会显示..
但是来自每个“tag”和“kategori”的imageId被称为
任何的想法?感谢

0 个答案:

没有答案
相关问题