gpt4 book ai didi

php - 我想从mysql中搜索图片

转载 作者:可可西里 更新时间:2023-11-01 07:39:08 24 4
gpt4 key购买 nike

首先,我想告诉你我正在使用 blob。所以,我上传了一些图片,我想创建一个搜索栏,这样我就可以通过数据库中的 tag 调用它。我现在的情况如下:

我无法搜索 2 个或更多单词。

我的数据库中有一个名为tagkategori 的字段。

tag 中,我放置了类似 zat 的数据;散文; obat ;

;(分号)分隔。

所以,这是我的一次搜索代码:

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

mysql_select_db("company");
echo($_POST["tag"]);
?>
<form method="POST" >
<font color='black'>Cari gambar:</font>
<input type="text" name="tag" value=" ">
<input type="submit" name="search" value="Cari"/>
</form>
<?php
if(isset ($_POST["tag"]))
{
$sql2="select imageId from output_images where bukuId=". $_GET["id"]." and tag like '%".$_POST["tag"]."%' Order by imageId asc";


}
else
{
$sql2="select imageId from output_images where bukuId=". $_GET["id"]." Order by imageId asc limit 1";

}`enter code here`
$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>

我怎样才能用 2 个或更多个字来完成?

我听说过 explode,但我不知道如何使用它。

this is my database, which use tag to find my image

最佳答案

在 mysql 查询中使用它:

WHERE interests REGEXP 'tag1|tag2|tag3'

关于php - 我想从mysql中搜索图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33345635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com