简体   繁体   中英

PHP Fetch Data From Database

在此输入图像描述

I'm trying to fetch data from hashtag where is #a2 or #ar hashtag but not work with my code

$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag=#a2");

try this,

$data = "#a2";
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag LIKE '%$data%'");
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag LIKE '%#a2%'");

You can also do it using your method but you just have to enclose #a2 in quotes like

$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag='#a2'");

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM