duancheng8000 2013-04-22 06:17
浏览 26
已采纳

从两个表中检索数据第一表文本数据第二表媒体图像。 图像失败[关闭]

Hello guys i have two tables one contains the property info and second is images of

property. i want to Retrieve the images of property from second table by selecting the

first table one row but it fails. it just display the info of property NOT images.

any one please?

  <html>
    <body>
    <?php
    require_once('db.php');
    if(isset($_POST['property']))
    {
        $property=$_POST['property'];
        $propertyquery = "SELECT PropertyImageID, PropertyName, PropertyStatus FROM properties WHERE PropertyImageID =$property ";
        $propertyquery_run= mysql_query($propertyquery);
       if (mysql_num_rows($propertyquery_run) > 0) 
          {
        while ($propertyrow = mysql_fetch_array($propertyquery_run)) 
          {?>
            <div>PropertyName: <?php echo $propertyrow['PropertyName']   ?>  </div>
            <div>PropertyStatus: <?php echo $propertyrow['PropertyStatus'] ?>  </div>


    <?php }

        $imagequery ="SELECT PropertyImageID, ImagePath FROM propertyimages WHERE PropertyImageID='".$propertyrow['PropertyImageID']."'";
         $imagequery_run=mysql_query($imagequery);
                if(mysql_num_rows($imagequery_run) > 0)  
                {
                    while ($imagerow = mysql_fetch_array($imagequery_run))  
                    {
                    ?>
                       <div style="border:solid 2px #9F0; border-radius:5px; height:222px; width:544px;">
                       <img src="<?php echo $imagerow['ImagePath'];  ?>" >
                       </div><br />    
                    <?php
                    }

                }
            }
    }
    else
    {
        echo 'Go Back And Set Your Session.Thanks';
    }
    ?>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • dongziduo9762 2013-04-22 06:20
    关注

    Your this lines

    $imagequery ="SELECT PropertyImageID, ImagePath FROM propertyimages WHERE PropertyImageID='".$propertyrow['PropertyImageID']."'";                                           
    $imagequery_run=mysql_query($imagequery);
    

    should be in while loop right now they are out of while loop.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)