Я получил изображения из базы данных, но у меня возникли проблемы с таймером ползунка, поэтому, когда он достигает последнего радиовхода, он возвращается к началу, а не к следующему, который пуст и затем возвращается к началу.
Любая помощь будет оценена.
<?php
session_start();
if(isset($_SESSION['user'])){
require 'includes/connect.php';
include('includes/functions.php');
$query = $conn->query("SELECT * FROM images");
$query2 = $conn->query("SELECT * FROM images");
$query3 = $conn->query("SELECT * FROM images");
$query4 = $conn->query("SELECT * FROM images");
$select = $conn->query("SELECT COUNT(id) as total FROM images");
?>
<html>
<head>
<title>Triology - Multi Sport Solutions </title>
<link rel="stylesheet" type = "text/css" href="css/style.css">
<link rel="stylesheet" type = "text/css" href="css/fonts.css">
<link href='https://fonts.googleapis.com/css?family=Titillium+Web' rel='stylesheet' type='text/css'>
<script src ="js/jquery-1.9.1.min.js"></script>
<script src ="js/script2.js"></script>
<script src ="js/script1.js"></script>
<script src ="js/script.js"></script>
<script src ="js/scroll.js"></script>
<script>
window.onload = function slider(){
<?php
$a = 1;
$b = 1;
$count = mysqli_fetch_array($select);
echo "var count = 1;
setInterval(function(){
if(count > ". $count['total'] ."){
count = 1;
}";
while($post = mysqli_fetch_array($query4)){
echo "if(document.getElementById(\"slide". $a++ . "\").checked){
count = ". $b++.";
count ++;
}";
}
echo "document.getElementById(\"slide\" + count++).checked = true;
}, 5000);";
?>
}
</script>
<title>CMS - Admin</title>
<link rel="shortcut icon" href="images/favicon.ico"/>
</head>
<body>
<!--Header holding the navigation and the logo-->
<div id ="accountBar" style = "color: white;">You are logged in! Welcome <?php echo $_SESSION['user'];?><a class = "logout" href = "logout.php">Log out</a></div>
<div id = "header">
<div id = "logo"></div>
<div id = "nav">
<ul>
<li><a href = "index.php">Home</a></li>
<li><a href = "store.php">Products</a></li>
<li><a href = "services.php">Services</a></li>
<li><a href = "about.php">About us</a></li>
<li><a href = "contact.php">Contact us</a></li>
<li><a href = "https://twitter.com/triologyuk"><img src = "images/twitterLogo.png" /></a></li>
<li><a href = "https://www.facebook.com/triologyuk"><img src = "images/facebookLogo.png" /></a></li>
<li><a onclick = "showSearch();"><img src = "images/searchButton.png" /></a></li>
</ul>
<div id = "searchBar" class = "hide">
<ul>
<header>Search...</header>
<li>
<form method = "post" action = "searchBrand.php">
<select name = "brand">
<option value = "">Search by Brand</option>
<?php
$result = $conn->query("SELECT * FROM brands");
while($cat = mysqli_fetch_array($result)){
?>
<option value ="<?php echo $cat['brand']?>"><?php echo $cat['brand']?></option>
<?php
}
?>
</select>
<input type = "submit" name = "submit" value = ""></input>
</form>
</li>
<li>
<form autocomplete="off" method = "post" action = "searchResults.php" size = "40" maxlength = "50">
<input id ="search" type = "text" name = "search" placeholder = "Search products..."/>
<input style = "top: 2px;" type = "submit" name = "submit" value = ""></input>
</form>
</li>
</ul>
</div>
</div>
<a href="#" class="scrollToTop"><img src = "images/top.png"/></a>
</div>
<div id = "mainWrapper">
<a id = "edit"href = "addImage.php">Add/ Delete Image</a>
<!--Slider-->
<div id ="retulLogo"></div>
<div id="slider">
<input checked="" type="radio" name="slider" id="slide1" selected="false">
<?php
$b = 2;
while($post3 = mysqli_fetch_array($query3)){
echo "<input type=\"radio\" name=\"slider\" id=\"slide" . $b++ . "\" selected=\"false\">";
}
?>
<div id="slides">
<div id="overflow">
<div class="inner">
<?php if($query->num_rows == 0){
echo "<td colspan = \"2\">There's no images in the database</td>";
} else {
while($post = mysqli_fetch_array($query)){
echo "<img src=\"data:image;base64," . $post['image'] . "\">";
}
}
?>
</div>
</div>
</div>
<?php
$a = 1;
while($post2 = mysqli_fetch_array($query2)){ echo "<label for=\"slide". $a++ . "\"></label>";
}
?>
</div>
<!--Menu holding swimming, running, swimming and events-->
<div id = "menuWrapper">
<ul>
<li>
<div id = "bikeIco"></div>
<header>Cycling Products</header>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</li>
<li>
<div id = "swimIco"></div>
<header>Swimming Products</header>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</li>
<li>
<div id = "runIco"></div>
<header>Running products</header>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</li>
</ul>
</div>
<!--New products, special offer and featured-->
<div id = "productsNav">
<ul>
<li><a onclick = "featuredProducts()" id = "featured" class = "active">Featured Products</a></a></li>
<li><a onclick = "newProducts()" id = "new" class = "notActive">New Products</a></li>
<li><a onclick = "specialOffers()" id = "special" class = "notActive">Special Offers</a></li>
</ul>
</div>
<div id = "productsWrapper">
<div id ="catWrapperF" class = "active">
<?php getFeatured();?>
</div>
<div id ="catWrapperN" class = "notActive">
<?php getNewProducts();?>
</div>
<div id ="catWrapperS" class = "notActive">
<?php getSpecialOffers();?>
</div>
</div>
<!--Logos footer-->
<div id = "logosFooter">
<ul>
<li><img src = "images/logo1.png"/><li>
<li><img src = "images/logo2.png"/><li>
<li><img src = "images/logo3.png"/><li>
<li><img src = "images/logo4.png"/><li>
<li><img src = "images/logo5.png"/><li>
</ul>
</div>
</div>
<!--Footer-->
<div id = "footer">
<ul id = "contact">
<header>Contact us</header>
<table>
<tr>
<td><img src = "images/address.png"></td><td>Ellerton on Swale,<br> Richmond North Yorkshire, DL10 6AP</td>
</tr>
<tr>
<td><img src = "images/email.png"></td><td><a href = "contact.php">Contact us by Email<a/></td>
</tr>
</table>
</ul>
<ul id = "contact">
<header>Opening Times</header>
<table>
<tr>
<td>Monday:</td>
<td>Tuesday:</td>
<td>Wednesday:</td>
</tr>
<tr>
<td>Thursday:</td>
<td>Friday:</td>
<td>Saturday:</td>
<td>Sunday:</td>
</tr>
</table>
</ul>
<ul id = "developer">Web Designer/ Developer Ryan North</ul>
</div>
<?php
} else {
header("Location: login.php");
}
?>
</html>
Я не могу правильно понять, что вы хотите …. но попробуйте это?
if(count >= ". $count['total'] .") ... (rest of code)
Других решений пока нет …