2016-07-21 332 views

回答

2

試試這個,

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

你忘了刪除'='#標籤 – Saurabh

+0

後應該是'$ =數據和addslashes( 「#A2」);?' – Jasen

+0

@Jasen爲什麼? –

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

你也可以使用你的方法做到這一點,但你只需要將#a2用引號括起來

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

希望它可以幫助