-1

enter image description here

<div id="demo" class="carousel slide" data-ride="carousel">
    <?php $count = count($veriler);?>
    <ul class="carousel-indicators">
    <?PHP 
     $i=0;
    for ($i=0;$i<$count;$i++) { ?>
        <li data-target="#demo" data-slide-to="<?php echo $i; ?>"></li>
    <?php }  ?>
    </ul>
    <div class="carousel-inner">
    <?php
    $j=0;
    foreach ($veriler as $row) {  ?>
        <div class="item <?php if($j==0) { echo "active"; } ?>">
            <div style="max-width:1100px; max-height:500px;">
                <img src=" <?php echo $row["haberekle_konu"]; ?>" alt="Los Angeles">
            </div>
            <div class="carousel-caption">
                <h3> <?php echo $row["haberekle_baslik"]; ?> </h3>
            </div>
        </div>
        <?php $j++; } ?>
    </div>
    <a class="carousel-control-prev" href="#demo" data-slide="prev">
        <span class="carousel-control-prev-icon"></span>
    </a>
    <a class="carousel-control-next" href="#demo" data-slide="next">
        <span class="carousel-control-next-icon"></span>
    </a>
</div>

i want to add in Carousel Slider a few images.

i posted image and caption from admin panel and i saved to database. when i extracted data from the database, result that: See i added the image. No picture display. enter image description here

<?php
    $veriler = $db->query("SELECT * FROM haberlerekle",PDO::FETCH_ASSOC)->fetchAll();
?>
i think, that codes need.
mali
  • 9
  • 2

2 Answers2

0

The symbol the top left cornor(https://i.stack.imgur.com/7UgIN.jpg) indicates a "broken link". This means, the path does not point on a File. Or u maybe need a absolute/relativ path(HTML showing broken image)

Make sure the path of the image u try to paste in the src-attribute is realy there.

U can try it by pasting the content of

$row["haberekle_konu"]

behind the URL. If the image not appear, the path ist not correct.

pdonkey
  • 21
  • 3
-1

Eventually i found the codes i was looking for. i found youtube. The codes and youtube link below.

Youtube Link

slider.php

    <?php
    $veriler = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id DESC LIMIT 12",PDO::FETCH_ASSOC)->fetchAll();
/*  $veriler = $db->query("SELECT * FROM haberlerekle ORDER BY haberekle_id DESC LIMIT 7"PDO::FETCH_ASSOC)->fetchAll();  */
    ?>
    
    <div id="demo" class="carousel slide" data-ride="carousel">
    <ul class="carousel-indicators">
    <?php
    $i = 0;
    foreach ($veriler as $row) {
        $actives = '';
        if($i == 0) {
            $actives = 'active';
        }
    ?>
    <li data-target="#demo" data-slide-to="<?php echo $i; ?>" class="<?php echo $actives; ?>"></li>
    <?php $i++; } ?>
    </ul>
    <div class="carousel-inner">
  
      <?php
        $i = 0;
        foreach ($veriler as $row) {
        $actives = '';
            if($i == 0) {
            $actives = 'active';
            }
      ?>
  
      <div class="carousel-item <?php echo $actives; ?>">
      <img src="upload/images/<?php echo $row['haberekle_konu']; ?>" width="832" height="502">
      <div class="carousel-caption">
      <p><?php echo $row["haberekle_baslik"]; ?></p>
      </div>   
      </div>
    
      <?php $i++; } ?>
    
      </div>
      <a class="carousel-control-prev" href="#demo" data-slide="prev">
      <span class="carousel-control-prev-icon"></span>
      </a>
      <a class="carousel-control-next" href="#demo" data-slide="next">
      <span class="carousel-control-next-icon"></span>
      </a>
      </div>

admin.php

        <?php
        if(isset($_POST['resimyukle'])) {
        $yazi = $_POST['haberekle_baslik'];
        $yukleklasor  = "../../../upload/images";
        $tmp_name     = $_FILES['yukle_resim']['tmp_name'];
        $name         = $_FILES['yukle_resim']['name'];
        $boyut        = $_FILES['yukle_resim']['size'];
        $tip          = $_FILES['yukle_resim']['type'];
        $uzanti       = substr($name,-4,4);
        $rasgelesayi1 = rand(10000,50000);
        $rasgelesayi2 = rand(10000,50000);
        $resimad      = $rasgelesayi1.$rasgelesayi2.$uzanti;
        
        //dosya var mı kontrol
        if(strlen($name) == 0) {
            echo "Bir Dosya Seçiniz";
            exit();
        }
        
        //boyut kontrol
        if($boyut > (1024*1024*3)) {
            echo "Dosya Boyutu Çok Fazla";
            exit();
        }
        
        //tip kontrol
        if($tip != 'image/jpeg' && $tip != 'image/png' && $uzanti != '.jpg') {
            echo "Yalnızca jpeg veya png formatında olabilir";
        }
        
        move_uploaded_file($tmp_name, "$yukleklasor/$resimad");
        
        $resimsor = $db->prepare("INSERT INTO haberlerekle set haberekle_konu=:ad, haberekle_baslik=:baslik");
        $resimyukle = $resimsor->execute(array('ad'=> $resimad, 'baslik'=> $yazi));
        
        }

        ?>
        
        <form action="" method="post" enctype="multipart/form-data">
        <input type="text" name="haberekle_baslik" size="100"></input><br><br>
        <input type="file" name="yukle_resim" /><br>
        <input type="submit" value="Yükle" name="resimyukle" />
        </form>

Thank you for your help.

mali
  • 9
  • 2