将存储过程结果返回到HTML表

时间:2017-03-01 15:17:33

标签: php html joomla html-table joomla3.0

我正在尝试执行以下语法,我想执行参数化存储过程并将结果返回到表中。直接在MSSQL中运行时,存储过程非常有效 - 但是当我尝试在我的文章中直接执行此操作时,我会收到500错误。

导致此问题的原因是什么?

{source}
<?php

    $d1 = $_GET['d1'];
    $d2 = $_GET['d2'];
    $name = $_GET['name'];

    $server = "server"; 
    $uid = "user"; 
    $pwd = "pwd"; 
    $database = "db"; 

    $conn = mssql_connect($server,$uid,$pwd);
    $proc = mssql_init('ProcName',$conn);
    mssql_bind($proc,'@d1',$d1,SQLVARCHAR);
    mssql_bind($proc,'@d2',$d2,SQLVARCHAR);
    mssql_bind($proc,'@name',$name,SQLVARCHAR);

    if ($result = mssql_execute($proc)) 
    {
        $number_of_rows = mssql_num_rows($result);
        if($number_of_rows > 0) {
    ?>
    <table border="1">
    <thead>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            <th>Header 3</th>
            <th>Header 4</th>
            <th>Header 5</th>
            <th>Header 6</th>
            <th>Header 7</th>
            <th>Header 8</th>
            <th>Header 9</th>
            <th>Header 10</th>
            <th>Header 11</th>
            <th>Header 12</th>
            <th>Header 13</th>
        </tr>
    </thead>
    <tbody>
        <?php
            foreach( $results as $res ) { 
                print "<tr>";
                    print "<td>" .$res->field1."</td>";
                    print "<td>" .$res->field2."</td>";
                    print "<td>" ."$".round($res->field3)."</td>";
                    print "<td>" ."$".round($res->field4)."</td>";                  
                    print "<td>" ."$".round($res->field5)."</td>";
                    print "<td>" ."$".round($res->field6)."</td>";
                    print "<td>" ."$".round($res->field7)."</td>";
                    print "<td>" ."$".round($res->field8)."</td>";
                    print "<td>" ."$".round($res->field9)."</td>";
                    print "<td>" ."$".round($res->field10)."</td>";
                    print "<td>" ."$".round($res->field11)."</td>";
                    print "<td>" ."$".round($res->field12)."</td>";
                    print "<td>" ."$".round($res->field13)."</td>";
                    print "<td>" ."$".round($res->field14)."</td>";
                print "</tr>";
            }
        ?>
  </tbody>
  </table>
{/source}

0 个答案:

没有答案