$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$stmt = $dbh->prepare("SELECT * FROM table where `time` > ? AND `time` < ? AND ticker = ?");
if ($stmt->execute(array($minTime, $maxTime, $ticker))) {
while ($row = $stmt->fetch()) {
print_r($row);
}
}
$dir = 'img/';
$images = scandir($dir);
for ($i = 0; $i < count($images); $i++) {
if ($images[$i] != '.' && $images[$i] != '..') {
echo '<a href="' . $dir . $images[$i] . '" target="_blank"><img src=' . $dir . $images[$i] . ' style="width: 200px;"></a>';
}
}
как сделать сортировку от конца
if ($result = mysqli_query($query)) {
$rows = mysqli_fetch_row($result);
foreach ($rows as $row) {
echo $row['id'];
echo $row['num'];
... тут сами уже решайте в каком виде выводить
}