The Script:
<?php
include("connect.php");
?>
<form method="POST" action="<?PHP echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name1" />
<input type="text" name="name2" />
<input type="text" name="name3" />
<input type="submit" name="submit" />
</form>
<?php
if(isset($_POST['submit'])){
$name1 = $_POST['name1'];
$name2 = $_POST['name2'];
$name3 = $_POST['name3'];
$myarray = array($name1, $name2, $name3);
for($i = 0; $i < count($myarray); $i++){
$tqs = "SELECT `id` FROM `images` WHERE `image_file` IN ('" . $myarray[$i] . "')";
$tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc));
$fetch_array = array();
$row = mysqli_fetch_array($tqr);
$fetch_array[] = $row['id'];
print_r($fetch_array);
}
}
?>
The script prints:
Array ( [0] => 558 ) Array ( [0] => 559 ) Array ( [0] => 560 )
How to have these values inside one array?
E.g.:
Array ( [0] => 558 [1] => 559 [2] => 560 )
The image file names come from the form and the values come from the ID column of the "images" table. And I am looking to have the selected stored inside one array.