我正在尝试从hashtag中获取数据,其中#a2或#ar hashtag但不能使用我的代码
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag=#a2");
答案 0 :(得分:2)
试试这个,
$data = "#a2";
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag LIKE '%$data%'");
答案 1 :(得分:1)
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag LIKE '%#a2%'");
答案 2 :(得分:0)
您也可以使用自己的方法进行操作,但只需将#a2
括在引号中,例如
$sql_query = mysqli_query($conn, "SELECT * FROM posts WHERE hashtag='#a2'");
希望有所帮助