从两个表中检索数据第一个表文本数据第二个表媒体图像.图像失败 [英] Retrieving data from two tables first table text data second table media images. the images fails

查看:46
本文介绍了从两个表中检索数据第一个表文本数据第二个表媒体图像.图像失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有两张表,一张是房产信息,一张是图片

财产.我想通过选择

从第二个表中检索属性的图像

第一个表一行但它失败了.它只显示属性而不是图像的信息.

请问有人吗?

 <身体><?phprequire_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);如果(mysql_num_rows($propertyquery_run)> 0){而 ($propertyrow = mysql_fetch_array($propertyquery_run)){?><div>PropertyName: <?php echo $propertyrow['PropertyName'] ?>

<div>PropertyStatus: <?php echo $propertyrow['PropertyStatus'] ?>

<?php }$imagequery ="SELECT PropertyImageID, ImagePath FROM propertyimages WHERE PropertyImageID='".$propertyrow['PropertyImageID']."'";$imagequery_run=mysql_query($imagequery);如果(mysql_num_rows($imagequery_run)> 0){而 ($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}}}}别的{echo '返回并设置您的会话.谢谢';}?></html>

解决方案

你的这行

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

现在应该在 while 循环中,但在 while 循环之外.

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>

解决方案

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.

这篇关于从两个表中检索数据第一个表文本数据第二个表媒体图像.图像失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆