I want to show the subcategory with and the list with
The query on line 25 fails because the '...IN ('".$base."')...'
must contain a series of values separated by commas inside the parentheses, type (1,2,3,4)
, and you are including a string that comes from doing a implode
separated by " "
instead of ","
.
$base
is a string since you fill it with a string when doing implode
, not an array, do not put $base[]
.
Try these changes.
Added to the answer: what was left to correct is that the implode must be done after the foreach, when the data array is already there, not while the elements are added.
$data = array ();
foreach ($resultado as $elemento) {
$data[] = $elemento["id"];
}
$string = implode (",",$data);