• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Trying to build dynamic table from Oracle query

Hi,
I am trying to build a dynamic HTML table from the results of an Oracle Query.  I have done this with MySQL, but the Oracle calls are much different (especially for a newbie).
My code is below...I think it's close, but still somewhat bungled up.  Can anyone please get this work?  There are 9 rows being returned from the query.
Thx,
Andy
<?php
   $conn = OCILogon('abcd', 'abcd', '//bsiaix6.abcd.com:1521/ABCD.bsiaix6') or die("ERROR CONNECTING - Notify Global Support");
   $query = "select literal_text from ci.literal where literal_group = 'Impacted Factors' order by seq_no";
   $stid = OCI_Parse($conn, $query);
   $r = OCI_Execute($stid, OCI_DEFAULT);
   if ($r)
   {
      echo "<table border=0>";
      oci_fetch_all($stid,$x);
      for ($i = 0; $i < oci_num_rows($stid); $i++) 
      {
         echo "<TR bordercolor=#ffff99>";
         $row = OCI_FETCH_ARRAY ($stid, OCI_ASSOC);
         while ($row = OCI_FETCH_ARRAY ($stid, OCI_ASSOC))
         {
            foreach ($row as $item)
            {
               echo "<TD width=858>" . "<font color=#990099>".  
               "<input type='checkbox' value = '$item' name = 'factors[]'>" . $item . 
               "</font>"."</td>";
            }  // End of FOREACH
         }  // End of While
      }  // End of FOR
     echo "</tr>";
     echo "</table>";
   }
   else
   {
      echo 'Unable to execute query.  Notify Global Support.';
   }  // end of IF
OCILogoff($conn);
?>

Open in new window

0
abrusko
Asked:
abrusko
  • 2
1 Solution
 
hernst42Commented:
Try this code

Your are reading the result set to often in your script, which prevents the output of anything.
<?php
$conn = OCILogon('abcd', 'abcd', '//bsiaix6.abcd.com:1521/ABCD.bsiaix6') or die("ERROR CONNECTING - Notify Global Support");
$query = "select literal_text from ci.literal where literal_group = 'Impacted Factors' order by seq_no";
$stid = OCI_Parse($conn, $query);
$r = OCI_Execute($stid, OCI_DEFAULT);
if ($r)
{
    echo "<table border=0>";
    while ($row = OCI_FETCH_ARRAY ($stid, OCI_ASSOC))
    {
        echo "<TR bordercolor=#ffff99>";
        foreach ($row as $item)
        {
            echo "<TD width=858>" . "<font color=#990099>".
            "<input type='checkbox' value = '$item' name = 'factors[]'>" . $item .
            "</font>"."</td>";
        }  // End of FOREACH
        echo "</tr>";
    }  // End of While
    echo "</table>";
} else {
    echo 'Unable to execute query.  Notify Global Support.';
}  // end of IF
OCILogoff($conn);
?>

Open in new window

0
 
abruskoAuthor Commented:
Leaving for the day...will try 1st thing in the a.m...thank you!
0
 
abruskoAuthor Commented:
Byoootiful...works perfectly...thank you very much!!!

Andy
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now