0
Good is the following I have an array designated by $posts, this $posts array is an array containing several things, such as: Work, Dinner, House, Outside.
What I want is to select a table in the database Where post=$posts, that is to all results, that are in the array?
How can I do that?
Thank you.
@EDIT:
echo $postosstring;
$procura1 = mysqli_query($link, "SELECT * FROM faturacoes where Status = 1 AND Data >= '$datainicial' AND Data <= '$datafinal' AND posto IN ('.$postosstring.')");
// Total Contratos
$resultset1 = mysqli_query($link, "SELECT SUM(contratos) as contratos FROM faturacoes where status='1' AND Data >= '$datainicial' AND Data <= '$datafinal' AND posto IN ('.$postosstring.')");
$linha1= mysqli_fetch_assoc($resultset1);
$soma1 = $linha1['contratos'];
// Total Valor
$resultset2 = mysqli_query($link, "SELECT SUM(valor) as valor FROM faturacoes where Status = 1 AND Data >= '$datainicial' AND Data <= '$datafinal' AND posto IN ('.$postosstring.')");
$linha2= mysqli_fetch_assoc($resultset2);
$soma2 = $linha2['valor'];
My SELECT is not working.
Explain this better.
– mau humor
I intend to do a select, where Where is an array, basically that’s it.
– Gonçalo
But what’s in that
array
? A list of the same field? if applicable, you can useWHERE IN
.– mau humor
I’ll try the Where in.
– Gonçalo
I think I got it wrong, it seems you want to create a query based on an array. If this is simple, it can be done with a simple iteration(foreach). Put your PHP code, if possible.
– mau humor