Trying to get an array from the database and use this array to execute a query like: " select from table where column like that array" .
after a search in many old questions, can't get a solution.
<?php
$mysqli = new mysqli("localhost", "hhtt", "htt", "htt");
/* Vérification de la connexion */
if ($mysqli->connect_errno) {
printf("Echec de la connexion : %s\n", $mysqli->connect_error);
exit();
}
$query = "SELECT site FROM user_info";
$result = $mysqli->query($query);
/* Tableau numérique */
while($row = $result->fetch_array())
{
$rows[] = $row;
}
$string = implode(' OR arrondissement LIKE ', $rows);
$query2 = "SELECT path FROM photos WHERE arrondissement LIKE {$string}";
$myArray = array();
$result2 = $mysqli->query($query2);
while($row2 = $result2->fetch_array(MYSQLI_ASSOC)) {
$myArray[] = $row2;
}
echo json_encode($myArray);
/*Fermeture de la connexion */
$mysqli->close();
?>
get json data from table using array in mysql query.