I am working on a PHP file and getting via POST this string:
$temas = $_POST['temas']; //$temas = ".45.12.34"
Where each of the numbers should be the id for a table record.
And I have following query
$query = "SELECT * FROM tb_preguntas WHERE tema = '".$temas."'";
I need to put in the WHERE part of the query each of the received id
Something like that: ... WHERE tema = 45 OR tema = 12 OR tema = 34
Of course, on each execution the string changes.
I have tried using the PHP explode function, but I don't know how to implement the result in the query.
trim($temas, '.');to remove any unnecessary periods, then you could dostr_replace('.', ',', $temas);to get it into the correct format for an SQL IN.... But i think really that's a really shitty answer for you :), this looks like an xy problem xyproblem.info. The way you're trying to do it is a bit shonky/dangerous, so a better answer for you would require more details, such as why is your POST format looking like ".45.12.34", can we improve that?$queryto?