0

I'm trying to fetch the image from my database using while loop in php but there's an error. can anyone help me? sorry for my bad english.

<div class="gallery" id="links">

                <?php
                     $query = $dbconn->query("select * from `uploading`") or die(mysqli_error());
                     while($fetch = $query->fetch_array()){
                                       ?>

                    <a class="gallery-item" href="artifactimage/<?php echo $fetch['artifact_image']; ?>" title="<?php echo $title ?>" data-gallery>
                        <div class="image">
                            <img src="artifactimage/<?php echo $fetch['artifact_image']; ?>" width="400" height="150" alt="<?php echo $fetch['artifact_name']; ?>" />
                            <ul class="gallery-item-controls">
                                <li><label class="check"><input type="checkbox" class="icheckbox" /></label></li>
                                <li><span class="gallery-item-remove"><i class="fa fa-times"></i></span></li>
                            </ul>
                        </div>
                        <div class="meta">
                            <strong>
                                <?php echo $fetch['artifact_name']; ?></strong>
                            <span>
                                <?php echo $fetch['artifact_desc']; ?></span>
                        </div>
                    </a>

                    <div id="preview"><img src="filed.png" /></div><br>

                <?php
    }

    ?>
</div>

The error:


Notice: Undefined variable: title in C:\xampp\htdocs\HAHMIS\artifactlist.php on line 9

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
JFranco30
  • 1
  • 2
  • 3
    "there's an error" What is the exact error? – Patrick Q Feb 21 '19 at 15:11
  • can you post the database schema of the table ? – Vidal Feb 21 '19 at 15:17
  • this is the error "
    Notice: Undefined variable: title in C:\xampp\htdocs\HAHMIS\artifactlist.php on line 9
    " I used ajax in this but it works. the only problem is that the image is not showing it only shows the alt text <?php echo $fetch['artifact_name']; ?>
    – JFranco30 Feb 21 '19 at 15:25
  • 1
    You are trying to use the variable `$title`, but you haven't defined it anywhere. – Patrick Q Feb 21 '19 at 15:28
  • should it not be `$fetch['artifact_title']` rather than simply`$title`? Pure guess btw – Professor Abronsius Feb 21 '19 at 15:29
  • Sorry for my question guys. I just got solve the problem a minute ago. thanks for your help anyways – JFranco30 Feb 21 '19 at 15:29
  • Possible duplicate of ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – user3783243 Feb 21 '19 at 15:37

0 Answers0