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

时间:2014-09-22 11:28:05

标签: php oracle

这里的第一次海报。

我目前正在为uni工作。作为其中的一部分,我必须从数据库中提取数据,并使用PHP文件在网页上显示所请求的信息,该文件链接到上一页的“搜索”表单。

我似乎无法将数据显示在表格中。

SQL语句已正确构建,数据库已正确链接并连接到,之前我已将此工作,直到我在格式化时进行了一些小改动。据我所知,一切都应该工作正常。有什么问题?任何帮助将不胜感激。

<!-- 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 个答案:

答案 0 :(得分:0)

嗯,自然在问了这个问题之后,看了几个小时,我发现了这个问题。

我有一行未正确评论O_O

对于任何有兴趣的人,我会留下这个,但是好主我觉得自己很蠢。随意锁定/删除此。

答案 1 :(得分:0)

-->添加到<!-- Start the main table的末尾,您就会感觉良好。您的所有代码都已注释掉;)

相关问题