我想在php块中传递m_id并显示所有检索图片

时间:2018-01-08 14:11:24

标签: php html mysqli

我想在同一页面上的这个query1块中传递m_id并检索特定机器的图像,但我无法帮助我。我想在div块上检索特定机器的图片,但它向我显示所有机器图片。所以我怎么能在这里传递m_id for sme block上的特定机器。

<?php

            $query1=mysqli_query($con,"select * from photo");
            while($row=mysqli_fetch_array($query1)){
                ?>
                <img src="<?php echo $row['location']; ?>" height="150px;" width="150px;">
                <?php
            }
        ?>

现在整个代码块在这里帮助我。

<div id="updateordinance2<?php echo $row['m_id'];?>" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
 <div class="modal-dialog">
      <div class="modal-content" style="height:auto">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">×</span></button>
                <h4 class="modal-title">Upload Multiple Image Of Machine</h4>
              </div>
              <div class="modal-body">
              <form class="form-horizontal" method="post" action="upload.php" enctype='multipart/form-data'>
        <div class="form-group">
          <div class="col-lg-9">
            <input type="hidden" class="form-control" id="price" name="m_id" value="<?php echo $row['m_id'];?>" readonly>
            <input type="file" name="upload[]" multiple>
            <!--input type="submit" value="Upload"-->           
          </div>
        </div>
        <?php
            //include('conn.php');
            $query1=mysqli_query($con,"select * from photo");
            while($row=mysqli_fetch_array($query1)){
                ?>
                <img src="<?php echo $row['location']; ?>" height="150px;" width="150px;">
                <?php
            }
        ?>
              </div>
              <div class="modal-footer">
        <button type="submit" class="btn btn-primary" value="Upload">Submit</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              </div>
              </form>
            </div>

        </div><!--end of modal-dialog-->
 </div>

2 个答案:

答案 0 :(得分:0)

您应该使用WHERE过滤数据以仅获取某些行。

答案 1 :(得分:0)

只需添加:

$m_id = $_POST['m_id'];
$query1=mysqli_query($con,"select * from photo where m_id = $m_id ");

希望这个帮助