只显示 sql 查询的第一行 [英] Only first row from sql query is displaying

查看:46
本文介绍了只显示 sql 查询的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在弹出窗口中显示产品说明.意思是当我点击产品链接时,将打开一个弹出窗口并显示产品说明.但这里有些不对劲.每个产品链接显示第一个产品说明.我的代码如下.请帮帮我.

Javascript:

 

HTML:

 <a href="javascript:displayPopup('flyBox')" title="查看大图" class="ui-icon ui-icon-zoomin">查看大图</a><div id="flyBox" style="display:none;"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><table border="0" cellspacing="0" cellpadding="0"><tr><td class="borderWindow"><div class="容器"><div id="closeButton"><a href="javascript:closePopup('flyBox')"><img src="http://i1122.photobucket.com/albums/l523/Long_Islander/flyBoxClose.png" width="28" height="28" alt="关闭按钮" border="0"/></a></div><div class="内容"><table width="600" border="0" cellspacing="20" cellpadding="0"><tr><td><div id="myMessageBox" name="myMessageBox"><table width="100%" border="0" cellspacing="2" cellpadding="0"><tr><td class="colheadingL"><font color="white">描述</font></td></tr><tr><td ><?php echo $img;?></td><td>书名:</td><td ><?php echo $row['pname'];?></td><td class="text1">MRP:</td><td><?php echo $row['price'];?></td></tr>

</td></tr>

</td></tr></td></tr>

但弹出是打开点击超链接.但问题是在所有产品中只显示第一个记录

解决方案

您的模板脚本中没有任何循环,这就是为什么您只能看到一条记录的可视化.

我不知道您的代码在您发布的代码段之外是如何组织的,但假设您的数据行位于 $rows 数组变量中,代码将如下所示:

<代码><tr><td ><?php echo $img;?></td><td>书名:</td><td ><?php echo $row['pname'];?></td><td class="text1">MRP:</td><td><?php echo $row['price'];?></td></tr><??>

My trying to show product desc in pop up. Mean when i click on product link then one pop up will open and show product desc. but here something is wrong. every product link showing first product desc. My code is Below. Please help me out.

Javascript:

    <script language="JavaScript">
    function displayPopup(alert_MSG) 
    {
       var theDetail = document.getElementById('flyBox');
            theDetail.style.display="block";
    }

    function closePopup(alert_MSG)
    {

        var theDetail = document.getElementById('flyBox');

        if (theDetail.style.display=="block") 
        {
            theDetail.style.display="none";
        }
    }
    </script>

HTML:

                        <a href="javascript:displayPopup('flyBox')" title="View larger image" class="ui-icon ui-icon-zoomin">View larger</a>
                      <div id="flyBox" style="display:none;">
                      <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>

                    <td align="center">
                    <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                    <td class="borderWindow">
                    <div class="container">
                    <div id="closeButton"><a href="javascript:closePopup('flyBox')"><img src="http://i1122.photobucket.com/albums/l523/Long_Islander/flyBoxClose.png" width="28" height="28" alt="Close Button" border="0" /></a></div>
                    <div class="content">
                    <table width="600" border="0" cellspacing="20" cellpadding="0">
                    <tr>
                    <td>
                    <div id="myMessageBox" name="myMessageBox">
                    <table width="100%"  border="0" cellspacing="2" cellpadding="0">
                    <tr>
                    <td class="colheadingL"><font color="white">Description</font></td>
                    </tr>
                    <tr>

                            <td ><?php echo $img; ?></td>
                            <td>Book Name:</td>
                            <td ><?php echo $row['pname']; ?></td>
                            <td class="text1">MRP:</td>
                            <td><?php echo $row['price'];?> </td>


                    </tr>



                </table>
                </div>
                </td>
                </tr>
                </table>
                </div>
                </div>
                </td>
                </tr>
                </table>
                </td>
                </tr>
                </table>
                </div> 

But pop up is open click on hyperlink. but problem is showing only 1'st record in all product

解决方案

You don't have loop any in your template script, that is why you see just one record vizualized.

I don't know exactly how your code is organized outside of the snippet you have posted, but assuming your data rows are in $rows array variable, the code will look something like that:

<? foreach($rows as $row) { ?>
<tr>
  <td ><?php echo $img; ?></td>
  <td>Book Name:</td>
  <td ><?php echo $row['pname']; ?></td>
  <td class="text1">MRP:</td>
  <td><?php echo $row['price'];?> </td>
</tr>
<? } ?>

这篇关于只显示 sql 查询的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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