3
Could you help me as I would concatenate strings in this search, passing which table is right if it would be i or c?
select i.nome from imovel i join cidade c
where c.nome in ("Campo Grande","Paranaíba")
and i.tipo in ("Casa","Apartamento")
and i.dormitorio in ("4","5")
function parseMysqlQuery($array) {
$output = '';
foreach ($array as $key => $value) {
$output .= !$output ? " WHERE $table.$key " : " AND $table.$key";
$output .= ' IN ("' . implode('","', $value) . '")';
}
echo "Key: $key; Value: $value<br />\n";
return $output;
}
$array = (array)filter_input_array(INPUT_POST,
array( 'num' =>
array( 'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_FORCE_ARRAY),
'grupo' => array(
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_FORCE_ARRAY,
),
'dt_de_inducao' => array(
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_FORCE_ARRAY,
),
)
);
//SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'folha_tarefa' if ($_SERVER['REQUEST_METHOD'] == "POST") { $array = array_filter($array);
$in = parseMysqlQuery($array);
$query = "SELECT * FROM contratos " . $in;.
This is a filter with checkbox, only I have a search that I do a Join left and I’m not getting my php to understand which table to search, ex nometable.
Could you be more specific in your question?
– Victor T.
Why opened two questions concerning the same subject, one of them being more incomplete?
– Ivan Ferrer
Because I am learning to use the site and had not seen the edit button, why I opened 2
– Gisele
Do you really need to adopt this misspelled method? One remark, "concatenation" does not exist, the correct one is "concatenation".
$table.$key
would benome_tabela.campo
and$value
the value of the table, then the correct one would be to pass an array structure that had each of these parameters. Being that$table
, is not part of the function, but an external variable.$array = array(array('campo'=>'valor'),array('campo'=>'valor'), ...);
– Ivan Ferrer
Thanks for the correction Ivan Ferrer, already corrected. well I need to do a filter and doing a search I found this method, (I am new in php programming), I started studying this code and I came across this problem of how to put the name of the table concatenated with the field, if you have any study link on the subject of filters so I can study thank you, I will try to use this form you wrote to me.
– Gisele