如果用户没有上传图片,请上传默认图片

时间:2018-01-17 06:08:45

标签: php sql

我创建了一个表并从数据库中获取数据......但如果用户没有上传任何图像,那么我该如何在此表中上传默认图像。

提前谢谢。

下面是从数据库中提取数据的表。

这是数据库连接:

<?php
    $con=mysqli_connect("localhost","krishna","krishna","krishna");

    if (!$con) {
    die("Connection failed: " . mysqli_connect_error());
    }
    ?>

下面是从数据库中获取数据的表

<table id="contact-list" border='1' class="tblListForm">
    <thead>
        <tr class="listheader">
             <th><input type="checkbox" name="select-all" id="select_all"></th>
             <th> id </th>
             <th> First name </th>
             <th> Last name </th>
             <th> User Name </th>
             <th> Gender </th>
             <th> Date Of Birth </th>
             <th> Email-Id </th>
             <th> Mobile Number </th>
             <th> Image </th>
             <th> Delete </th>
        </tr>
    </thead>

 <?php
    $result = mysqli_query($con,"SELECT * FROM employe");
    while($row = mysqli_fetch_array($result))
    {
        // Change Date Format
    $date = date('m-d-Y', strtotime(str_replace('/','-,$row['date_of_birth'])));
    ?>
    <!-- fetching data from database --> 
    <tbody>`enter code here`
     <tr>
        <td><input type ='checkbox' value="<?=$row['select']?>"="<?=$row['select']?>" class="allcheckbox">
        <td><?php echo $row['id'];?></td>
        <td><?php echo  $row['firstname'];?></td>
        <td><?php echo $row['lastname'];?></td>
        <td><?php echo $row['username'];?></td>
        <td><?php echo $row['gender'] ;?></td>
        <td><?php echo  $date;?></td>
        <td><?php echo $row['email'];?></td>
        <td><?php echo $row['mobile_no'];?></td>
        <td><img src="image/<?php echo $row['image'];?>" style="width:100px;height:100px;"></td> <!-- this is image that i fetched from my database -->
        <td><form action='delete.php?name="<?php echo $row['id']; ?>" method="post"'><input type="hidden" name="id" value="<?php echo $row['id']; ?>"><input type="submit" name="submit" value="Delete"></form>
        </td>
    </tr>
    </tbody>

    <?php
    }   
    ?>
</table>

0 个答案:

没有答案