当前位置: 首页 > 面试题库 >

sql查询的第一次迭代未正​​确包装

沈枫涟
2023-03-14
问题内容

所以,我有这个php文件,但是第一个结果没有被包装在’result’div中,因此样式也不正确。所有后续结果均已正确包装。帮助?

编辑:根据评论,我试图拉出html。我承认我是菜鸟,但这是我想出的。似乎无法解决原始问题:

scripts_post.php:

$connection = mysqli_connect("server", "user", "password", "dbname");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($connection, $sqlQuery);
mysqli_close($connection);
if (empty($result)) { 
    echo 'No results found'; 
    return;
}
while($row = mysqli_fetch_array($result))
    {
        echo include 'single_result.php';
    }
echo "<div class='results_end'><p>End of list</p></div>";

single_result.php:

    <div class='result'>
        <div class='result_left'>
            <div class='result_photo'><img src=<?php echo "'" . $row['PhotoLink'] . "'" ?> height='200' width='200' class='script_photo'></div>
        </div>
        <div class='results_right'>
            <div class='result_title'><?php echo $row['Title'] ?></div>
            <div class='result_summary'><?php echo $row['Summary'] ?></div>
            <div class='result_description'><?php echo $row['Description'] ?></div>
            <div class='result_preview'><a href =<?php echo "'" . $row['PreviewLink'] . "'" ?> target='_blank'>view preview</a></div>         
            <div class='result_detail'>Type: <?php echo $row['Type'] ?></div>   
            <div class='result_detail'>Biblical Characters Portrayed: <?php echo $row['BiblicalCharacters'] ?></div>
            <div class='result_detail'>Topics: <?php echo $row['Topics'] ?></div>
            <div class='result_price'>Cost: $<?php echo $row['Price'] ?></div>
            <div class='result_purchase'><a href =<?php echo "'" . $row['DownloadLink'] . "'" ?> target='_blank'><img src='http://image.payloadz.com/images/btn-addtocart-b.png' border='0'></a></div>
        </div>
    </div>

编辑#2:这就是上面所说的。也许这里有些东西缠着东西?

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js">
    </script>
    <script language ="javascript">
        $(function() {
            $('form').submit(function(event) {
                var form = $(this);
                $.ajax({
                    type: form.attr('method'),
                    url: form.attr('action'),
                    data: form.serialize()
                }).done(function(returned_data) {
                    document.getElementById('scriptsearch_results_div').innerHTML = returned_data;
                }).fail(function() {
                    alert("The search has failed.  Please alert the webmaster.");
                });
                event.preventDefault();
            });
        });
    </script>
    ...
    <div id="formcontainer">
        <form id="scriptsearch_form" action="scripts_post.php" method="post">
            // form fields
            <p> <input type="submit" value="Search" class="submitbutton" id="mainsubmitbutton"> </p>
        </form>
    </div>
    <div id="scriptsearch_results_div">
        <p>Search for scripts using the options at left.</p>
    </div>

问题答案:

找到了问题。真的很傻 <body>实际上是scripts_post.php中的标签,<body因此第一个操作>是关闭标签,然后将其间的内容转储。



 类似资料:
  • 我正在对PeopleSoft数据库进行查询,不确定是否可以根据初始查询在一次调用中从同一个表中获取信息。例如,我正在访问的表返回EmployeeID、FullName、FirstName、LastName、Position\u NBR和ReportsTo。但是ReportsTo是以经理的Position\u NBR(在同一个表中找到)的形式提供的,我想以name格式提供。我想这样做,但不确定是否可

  • 问题内容: 在注意到Django的某些内置查询效率低下之后,一直在编写一些原始SQL查询。我试图遍历结果并将其分组(我知道模板标签,这对我不起作用- 我需要能够独立访问单独的组)。这是我的代码: 这给了我我想要的东西(例如,我可以访问的列表),但是它为每次迭代运行一个数据库查询以获取字段。我尝试在循环之前添加,没有效果。 有人可以帮我从这里出去吗?这似乎应该很简单。 谢谢,马特 问题答案: 编辑:

  • 问题内容: 有没有一种优雅的方法可以跳过Java5 foreach循环中的第一次迭代? 伪代码示例: 问题答案: 我不会称其为优雅,但可能比使用“第一个”布尔值更好: 除此之外,可能没有优雅的方法。

  • 问题内容: 在下面的代码中,迭代运行两次。 是否可能恰好在第一次迭代和第二次迭代之间运行“ test2 <-true”? 我的意思是,在第一次迭代结束而第二次迭代未开始时,是否将true发送给“ test2”? 问题答案: 是。由于您的频道已缓冲,可以保存1个值。主执行流程可以继续进行,而无需您的匿名goroutine读取您发送到通道的值,并且可以在goroutine唤醒并读取通道上的值之前在通道

  • 问题内容: 我想每隔3个帖子通过XML回显图像,这是我的代码: 这是一个示例,前3个是正确的,但现在不会循环idgc.ca/web-design-samples-testing.php 问题答案: 最简单的方法是使用模数除法运算符。 工作原理:模数除法返回余数。当您为偶数倍时,余数始终等于0。 有一个陷阱:等于0。如果您的计数器从0开始,可能会导致意外结果。

  • 我正在通过Spark Cassandra连接器应用以下内容: