0

Im trying to display all the movies with specific hashtag.

The results are not showing but there are no errors.

However i should get movie poster image and title as result. :/

In my database, this is 'tags' row of one movie

#watchonline #movies-with-subs #hdmovies

and tag.php

<?php
require "db.inc.php";

if (isset($_GET['tag'])) {
$tag = preg_replace('#[^a-z0-9_-]#i', '', $_GET["tag"]);
$fulltag = "#" . $tag;
echo $fulltag;
$ASDsql = "SELECT * FROM movie WHERE tags LIKE '$fulltag' OR tags = 
'$fulltag'";
$tagQuery = mysqli_query($db, $ASDsql);

$count = mysqli_num_rows($tagQuery);
if($count > 0) {
while ($hastags = mysqli_fetch_array($tagQuery)) {
$id = $hastags['id'];

$movie_title = $hastags['movie_title'];

$movie_url = $hastags['movie_url'];

$movie_image = $hastags['movie_image'];


$movie_identity = $hastags['movie_identity'];

echo "<div class='item'><a href='movie.php?movie=$id'><img 
src='$movie_image'><p>$movie_title</p></a></div>";
}
}else {
echo "No movies under that tag";
}
}
?>

I've checked db.inc.php file it's all good. My output is "No movies under that tag"; Im sorry if this is a copy i really looked and could not find an answer

8
  • You need to explain what the error is, what the output is and the expected result. Commented Feb 10, 2018 at 16:58
  • I don't get any error, only the output "No movies udner that tag" Commented Feb 10, 2018 at 16:58
  • LIKE usually requires a % or _, like so: ...where tags like '%test%' Commented Feb 10, 2018 at 17:00
  • Tried still same thing. Commented Feb 10, 2018 at 17:02
  • Try var_dump($tagQuery); This will let you see what is being returned from the Query Commented Feb 10, 2018 at 17:04

1 Answer 1

1

try this :

 $ASDsql = "SELECT * FROM movie WHERE tags LIKE '%$fulltag%' OR tags = 
'%$fulltag%'";

or may be the table is not having any value

Sign up to request clarification or add additional context in comments.

4 Comments

It worked. It seem "LIKE" was not necessary at all. The working output is $ASDsql = "SELECT * FROM movie WHERE tags = '%$fulltag%'";
does your column tags have value starting with "%" since you are equating with that
No they are like this #tag. however i have litle function that convert any hashtag string (#string) into clickable link
how can you get the result by condition where tags='%$fulltag%' ,since this contain a character % in the start hence the condition will match with % not with # and you are also not using like query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.