dongweng6241 2014-09-22 11:28
浏览 24
已采纳

将数据库数据显示到php表中

First time poster here.

I'm currently working on an assignment for uni. As part of it, I have to extract data from a database and display the requested information on the web page using a PHP file, linked to a 'search' form on the previous page.

I can't seem to get the data to display into the table though.

The SQL statement has been constructed correctly, the database has been properly linked to and connected to, and I had this working previously, until i made a small change while formatting. From what I can tell everything should be working fine. What is the issue? Any help will be greatly appreciated.

<!-- Start the main table
                  <?php
                     if ($howmany > 0) {
                     echo("<table width=".$tablewidth." border=0 bgcolor=#339933 cellpadding=5 cellspacing=1>");
                     echo("<tr bgcolor=#006633>");
                     echo("<td width=200 style=color:#ffff99;text-align:center>Item Name</td>");
                     echo("<td width=200 style=color:#ffff99;text-align:center>Item Price</td>");
                     if ($PHOTO != "") echo("<td width=200 style=color:#ffff99;text-align:center>Photo</td>");
                     if ($DESCRIPT != "") echo("<td width=200 style=color:#ffff99;text-align:center>Item Description</td>");

                     }
                     ?>

                    <?php
                     while(OCIFetch($stmt))  
                     {

                     // Start a row for each record

                     echo("<tr valign=top bgcolor=#ccffcc>");   

                     // Output fields, one per column

                     // Name in column one
                     $fg6 = OCIResult($stmt, "ITEM");
                      echo("<td width=200 align=center>");
                     echo ($fg6);
                     echo("</td>"); 

                     // Price in column two
                     $fg7 = OCIResult($stmt, "PRICE");
                     echo("<td width=200 align=center>");

                     echo ($fg7);
                     echo ("</td>");

                     // Photo in column three

                     if ($PHOTO != "")
                     {
                     // Pictures are in assignment 2 stage 2 directory
                     $fg1 = OCIResult($stmt, "PHOTO");
                     echo("<td width=200 align=center>");
                     echo ("<br><img src=MYUNI/ASSIGNMENT/IMAGESOURCES/".$fg1."><br>");
                     echo ($fg1);
                     echo("</td>"); 
                     }
                     // Description in column four

                     if ($DESCRIPT != "")
                     {
                      $fg2 = OCIResult($stmt,"DESCRIPT"); 
                     echo("<td width=200 align=center>");
                     echo ($fg2);
                     echo("</td>");
                     }
                     // End the row 
                     echo("</tr>");
                     }
                     // Close the connection
                     OCILogOff ($connect); 

                     ?>
                              <!-- Close the table itself -->
               <?php
                  if ($howmany>0) {
                    echo("</table>");
                    echo("</div>");
                  }
                  ?>
  • 写回答

2条回答 默认 最新

  • doujiu9172 2014-09-22 11:37
    关注

    Add --> to the end of your your <!-- Start the main table and you'll be good. All your code is commented out ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?