How to upload a slider (carousel) from the database?

How to upload a slider (carousel) from the database?

meriammeriam Posts: 2Questions: 1Answers: 0

I used the following code to upload the images,
I would like to turn these images into sliders, and have an automatic code.
without having to change the name of the image each time.

addimage.php

( <?php $msg = ""; require'connect.php'; // quand tu tape sur le button upload if(isset($_POST['upload'])){ $target = "photos2/".basename($_FILES['image']['name']); $image = $_FILES['image']['name']; $nom = $_POST['nom']; $text = $_POST['text']; $sql = "INSERT INTO slider (image,nom,text) VALUES ('$image', '$nom', '$text')"; mysqli_query($db,$sql); if(move_uploaded_file($_FILES['image']['tmp_name'],$target)){ $msg = "image uploaded successfully"; }else{ $msg = "error_uploaded"; } } ?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--meta pour un site responsive dans tous les appareilles-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags must come first in the head; any other head content must come after these tags -->
<title></title>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="shortcut icon" href="image/icone.png">
<!-- Bootstrap -->
<link rel="stylesheet"href="bootstrap/css/bootstrap.min.css">

<!-- my style css -->
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

</head>
<body>

Add Sliders

</body>
</html>.php

<?php ) ****************************************************************************************************************************** image.php to display the images ( require 'connect.php'; $sql = "SELECT * FROM slider"; $result = mysqli_query($db,$sql); ?>
</style>

<?php while($row= mysqli_fetch_array($result)){ echo "<div id='img_div'>"; echo "

".$row['id']."

"; echo "

".$row['nom']."

"; echo "image"; echo "

".$row['text']."

"; ?>
   <a href="deleteSlider.php?q=<?=$row['id'] ?>"><i class="fa fa-trash-o text-danger" aria-hidden="true"></i></a>

   <a href="editSlider.php?q=<?=$d['id'] ?>"><i class="fa fa-pencil-square-o text-info" aria-hidden="true"></i></a>

      <?php 
      echo "</div>";
      }
  ?>)

Thanks for your help

Answers

This discussion has been closed.