Обучение/Помощь новичкам | Проблема отображения и воспроизведения видеоматериалов
Посмотрите на этот код, где-то он не работает. Если понимаете, исправьте, пожалуйста!!!
$stmtD = $pdo->prepare("SELECT * FROM `download__files` ORDER BY id DESC");
[/code][code=php]
// Change 'articles' to your table name
$stmt->execute();
$stmtD->execute();
// Fetch all rows as an associative array
$rows = $stmtD->fetchAll(PDO::FETCH_ASSOC);
// If no rows, show a message
if (empty($rows)) {
echo "No articles found in the database.";
} else {
echo "Article Links:";
// Loop through each row and echo the link
foreach ($rows as $row) {
// Escape outputs for safety
$safe_id = (int)$row['id']; // Cast to int for security
$safe_name = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$safe_nameT = htmlspecialchars($row['rus_name'], ENT_QUOTES, 'UTF-8');
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_name . ' [/url]
';
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_nameT . ' [/url]
';
[/code][code=php] }
}
} catch (PDOException $e) {
// Handle connection or query errors
echo "Error: " . $e->getMessage() . "";
}
[/code][code=php]// Close the connection (PDO does this automatically at script end)
$pdo = null;
?>
$stmtD = $pdo->prepare("SELECT * FROM `download__files` ORDER BY id DESC");
[/code][code=php]
// Change 'articles' to your table name
$stmt->execute();
$stmtD->execute();
// Fetch all rows as an associative array
$rows = $stmtD->fetchAll(PDO::FETCH_ASSOC);
// If no rows, show a message
if (empty($rows)) {
echo "No articles found in the database.";
} else {
echo "Article Links:";
// Loop through each row and echo the link
foreach ($rows as $row) {
// Escape outputs for safety
$safe_id = (int)$row['id']; // Cast to int for security
$safe_name = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$safe_nameT = htmlspecialchars($row['rus_name'], ENT_QUOTES, 'UTF-8');
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_name . ' [/url]
';
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_nameT . ' [/url]
';
[/code][code=php] }
}
} catch (PDOException $e) {
// Handle connection or query errors
echo "Error: " . $e->getMessage() . "";
}
[/code][code=php]// Close the connection (PDO does this automatically at script end)
$pdo = null;
?>
Посмотрите на этот код, где-то он не работает. Если понимаете, исправьте, пожалуйста!!!
$stmtD = $pdo->prepare("SELECT * FROM `download__files` ORDER BY id DESC");
[/code][code=php]
// Change 'articles' to your table name
$stmt->execute();
$stmtD->execute();
// Fetch all rows as an associative array
$rows = $stmtD->fetchAll(PDO::FETCH_ASSOC);
// If no rows, show a message
if (empty($rows)) {
echo "No articles found in the database.";
} else {
echo "Article Links:";
// Loop through each row and echo the link
foreach ($rows as $row) {
// Escape outputs for safety
$safe_id = (int)$row['id']; // Cast to int for security
$safe_name = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$safe_nameT = htmlspecialchars($row['rus_name'], ENT_QUOTES, 'UTF-8');
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_name . ' [/url]
';
echo '[url=/downloads/?act=view&id=' . (int)$safe_id . ']' . $safe_nameT . ' [/url]
';
[/code][code=php] }
}
} catch (PDOException $e) {
// Handle connection or query errors
echo "Error: " . $e->getMessage() . "";
}
[/code][code=php]// Close the connection (PDO does this automatically at script end)
$pdo = null;
?>
php
try { $stmtD = $pdo->prepare("SELECT * FROM `download__files` ORDER BY id DESC"); $stmtD->execute(); // Fetch all rows as an associative array $rows = $stmtD->fetchAll(PDO::FETCH_ASSOC); // If no rows, show a message if (empty($rows)) { echo "No articles found in the database."; } else { echo "Article Links:<br>"; // Loop through each row and echo the link foreach ($rows as $row) { // Escape outputs for safety $safe_id = (int)$row['id']; $safe_name = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8'); $safe_nameT = htmlspecialchars($row['rus_name'], ENT_QUOTES, 'UTF-8'); echo '[url=/downloads/?act=view&id=' . $safe_id . ']' . $safe_name . ' [/url]<br>'; echo '[url=/downloads/?act=view&id=' . $safe_id . ']' . $safe_nameT . ' [/url]<br>'; } } } catch (PDOException $e) { // Handle connection or query errors echo "Error: " . htmlspecialchars($e->getMessage()) . "<br>"; } // Close the connection (PDO does this automatically at script end) $pdo = null; ________
посл. ред. 13.02.2026 в 20:42; всего 2 раз(а); by 854278358
Иди на официальный сайт поддержки johncms там и узнаешь ответы на это непонятно чтоо
php
<?php try { $stmtD = $pdo->prepare("SELECT * FROM download__files ORDER BY id DESC"); $stmtD->execute(); $rows = $stmtD->fetchAll(PDO::FETCH_ASSOC); if (empty($rows)) { echo "Файлов не найдено."; } else { foreach ($rows as $row) { $id = (int)$row['id']; $name = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8'); $rus = htmlspecialchars($row['rus_name'], ENT_QUOTES, 'UTF-8'); echo '<a href="/downloads/?act=view&id=' . $id . '">' . $name . '</a><br>'; echo '<a href="/downloads/?act=view&id=' . $id . '">' . $rus . '</a><br><br>'; } } } catch (PDOException $e) { echo "DB error: " . $e->getMessage(); } $pdo = null; ?> ________
посл. ред. 13.02.2026 в 21:46; всего 3 раз(а); by E-Vine