Jump to content

raldje

Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About raldje

  • Rank
    Newbie
  1. $donnees = $stmt->fetch_all(); Fatal error: Call to undefined method PDOStatement::fetch_all()
  2. <?php $stmt = $bdd->query('SELECT image FROM matable'); $donnees = $stmt->fetchAll(); var_dump($donnees); $images = $donnees['image']; echo '<img src="image/'.$images.'" id="my-image" />'; ?> <script type="text/javascript"> var imgs = new Array( <?php for ($i = 0; $i < count($images); $i++) { echo '"'. htmlspecialchars($images[$i]) .'"'; if ($i < count($images) -1) { echo ','; } } ?> ); var position = 0; var taille = imgs.length; var image = document.getElementById('my-image'); changeImage = function() { position = (position+1 >= taille) ? 0 : position+1; image.src = imgs[position]; setTimeout(changeImage, 1000); } changeImage(); </script> I think it's something like that but it don't work.
  3. Exactly what i'm looking for, but i don't know how to do. I tried different way to do this without success.
  4. Happy new year everybody. Thank you Dsonesuk, it's work. Is it possible to do it without ajax?
  5. I'l try to explain with more precision. In my table i have several entries of event, some with image, some without I also have an image by default . I try to make a header with all the present images in my table switching every 10 seconds, or my image by default if no event or only events without image.
  6. $rst = $bdd->query('SELECT image from matable order by Rand() LIMIT 0, 1'); while($donnees = $rst->fetch()) { $image = nl2br($donnees['image']); echo '<img src="defaultimg.jpg" alt="image_by_default" id="img1"/>'; echo '<img src="image/'.$donnees['image'].'" alt="image" id="img2"/>'; } $rst->closeCursor(); <script> var x=1; var myVar = setInterval(myTimer, 1000); function myTimer() { if(x%2==0){ document.getElementById("img1").style.display = "none"; document.getElementById("img2").style.display = "block"; x=1; } else{ document.getElementById("img2").style.display = "none"; document.getElementById("img1").style.display = "block"; x=2; } } </script> When i load the page i see 2 images and after 1 second, it's working. But it's only switch beetween default_img and first event image, i got several events with image in my table. I realy don't know how to do this.
  7. $rst = $bdd->query('SELECT image from matable order by Rand() LIMIT 0, 1'); while($donnees = $rst->fetch()) { $image = nl2br($donnees['image']); echo '<img src="defaultimg.jpg" alt="image_by_default" id="img1"/>'; echo '<img src="image/'.$donnees['image'].'" alt="image" id="img2"/>'; } $rst->closeCursor(); <script> var x=1; var myVar = setInterval(myTimer, 1000); function myTimer() { if(x%2==0){ document.getElementById("img1").style.display = "none"; document.getElementById("img2").style.display = "block"; x=1; } else{ document.getElementById("img2").style.display = "none"; document.getElementById("img1").style.display = "block"; x=2; } } </script> When i load the page i see 2 images and after 1 second, it's working. But it's only switch beetween default_img and first event image, i got several events with image in my table. I realy don't know how to do this.
  8. Hi, first sorry for my english, i'm french i got a table in my database to announced events with this fields: id, event_date, announce, image. I want to make a header with images changing each 10 secondes, but i don't want to refresh all the page. This is what i use actually: $rst = $bdd->query('SELECT image from matable order by Rand() LIMIT 0, 1'); while($donnees = $rst->fetch()) { $image = nl2br($donnees['image']); if (empty($image)) { echo '<img src="imagedefaut.jpg" />'; } else { echo '<img src="image/'.$donnees['image'].'" alt="image"/>'; } } $rst->closeCursor(); I know i have to use some javascript with setInterval but i don't know how to do. Can i have some help, please.
×
×
  • Create New...