Мне нужно свежую пару глаз, чтобы посмотреть на это!Включая бутстрап и js в php
Я принял код непосредственно из одного из моих старых сценариев https://jsfiddle.net/RachGal/fs9u6mwe/1/, чтобы отображать фотографии в галерее кампуса колледжа. Однако он показывает только один. Когда я включаю bootstrap и функцию в моем php, она, похоже, не читает ее! Почему это может быть?
Мой PHP выглядит следующим образом
<?php
echo "<html><head><meta charset='utf-8'>";
echo "<script type='text/javascript' src='scripts/bootstrap.js'></script>";
echo"<link rel='stylesheet' type='text/css' href='css/style.css'>";
include "scripts/show.php";
echo" <title>Gallery Display</title></head><body>";
echo "<header>";
echo "<h1>The Ultimate Gallery Compiler</h1>";
echo "<div id='menu'><a class='head' href='index.html'>Upload Photo</a> <a class='head' href='gallery.html'>Browse Gallery</a></div>";
echo "</header>";
echo "<div id='content'>";
echo "<h2>Browse Gallery</h2>";
$subfolder = $_POST["category"];
if ($subfolder == "0"){
echo("Please <a href='gallery.html'>go back</a> and select a category");
echo "</div><br><br>";
echo "<footer>";
echo "<p class='foot'>© Copyright 2015-2016 MMA2 Rachel Gallen, Ysabel Pheifer and Rebecca Merrigan.</p>";
echo "</footer>";
exit();
}
$countcontents = file_get_contents("categories.txt"); //read file to get count
$countarray = explode('*', $countcontents); //get count of each category into an array
$categories = array("fashion", "music", "sports", "technology", "animals", "health", "other");
//output title according to if the gallery has images in it or not
for($i=0; $i< count($countarray); $i++)
{
if ($subfolder == $categories[$i]){
if (intval($countarray[$i]) == 0) {
echo "<h3>No images have been uploaded for the " .$subfolder. " category yet</h3>";
}
else
{
echo "<h3>Here are the images for the " .$subfolder. " category</h3>";
echo "<p>There are ".$countarray[$i]." photos in this category</p><br>";
}
}
}
$folder = "images/".$subfolder."/";
// Open the appropriate subfolder, and display its contents.
// http://php.net/manual/en/function.opendir.php
// also referenced https://www.youtube.com/watch?v=nGLi4ykt__0
if ($dir = opendir($folder)) {
$images = array();
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
$images[] = $file;
}
}
closedir($dir);
}
echo '<div id="slider">';
echo "<ul id='slides'>";
foreach($images as $image) {
echo '<li class="slide"><img src="';
echo $folder.$image;
echo '" alt=""/></img></li>';
}
echo "</ul>";
echo '</div>';
echo "<p> </p><a href='gallery.html'>Reselect</a>";
echo "</div>";
echo "<footer>
<p class='foot'>© Copyright 2015-2016 MMA2 Rachel Gallen, Ysabel Pheifer and Rebecca Merrigan.</p>
</footer>";
echo "</body></html>";
?>
Любая помощь будет оценен по достоинству!
кстати браузер
//Reference https://jsfiddle.net/RachGal/fs9u6mwe/1/
$(document).ready(function() {
//INDEX IMAGES SLIDER
$(function slider() {
//configuration
var width = 360;
var speed = 1000;
var pause = 3000;
var current = 1;
//cache DOM
var $slider = $('#slider');
var $slides = $slider.find('#slides');
var $slide = $slides.find('.slide');
setInterval(function() {
//move image the defined width and speed to the left
$slides.animate({
'margin-left': '-=' + width
}, speed, function() {
//count number of slides and loop back to first from last
current++;
if (current === $slide.length) {
current = 1;
$slides.css('margin-left', 0);
}
});
}, pause);
});
}
);
Это связано с '$ subfolder = $ _POST [" category "];' - 'Примечание: Неопределенный индекс: category' - POST не работает и опирается на форму (?). Вероятно, должно быть GET, но не знаете, где это происходит. –