I have two problems...
Here is code :

<?php
// Create connection to Oracle
$conn = oci_connect("root", "admin", "//127.0.0.1/xe");
$query = 'select * from TEST_RESULTS';
$stid = oci_parse($conn, $query);
$r = oci_execute($stid);

print '</br>';
// Fetch each row in an associative array
print '<b> MONITORING SRODOWISK TESTOWYCH </br>';
print '</br>';

print '<table border="1">';
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
   print '<tr>';
   foreach ($row as $item) {print '<td>'.($item !== null ? htmlentities($item, ENT_QUOTES) : '&nbsp').'</td>';}
   print '</tr>';
}
print '</table>';

?>

on my local website , I have table :

id result1 result2 result3 resul4

  1. ok ok ok pass
  2. nok ok ok fail
  3. ok nok ok fail
    ...
    1) firstly , I need add column headings, because now I do not have
    2) I would like change my background( bgcolor="#FF0000" ) color in every row when result4 = fail
    Please any suggestions how to best do this
    thx !

Recommended Answers

All 4 Replies

<table broder="1">
          <tr>
            <td>Result 1</td>
            <td>Result 2</td>
            <td>Result 3</td>
            <td>Result 4</td>
          </tr>

Then step through your while loop.

For changing colour:

if $result4 =='fail'{
    do this
}

I improve code, but I still Have problem with change color in row when is 'fail' value.. how do this

<?php
$conn = oci_connect("root", "admin", "//127.0.0.1/xe");
$query = 'select * from TEST_RESULTS';
$stid = oci_parse($conn, $query);


$stmt=oci_parse($conn,'select * from TESTS');


$ret=oci_execute($stmt);
$nrows=oci_fetch_all($stmt,$results);


if ($nrows>0)
{
echo "<table border='1' align='center' bordercolor='gray' cellspacing='0' cellpadding='5'> \n";
echo "<tr>\n";

foreach ($results as $key => $val)
{ echo "<th bgcolor='#FF9900' height='20' align='center'> <font color='white' face='verdana' size='2'> $key </font> </th> \n";
}
echo "</tr>\n";


for ($i=0; $i<$nrows; $i++) {
echo "<tr>\n";

foreach ($results as $data){

if($data[$i] == null)
{
   echo "<td bgcolor='white'  align='center'> <FONT COLOR='black' FACE='verdana' align='center' SIZE='3'>   </FONT> </td>\n";
}
else
{
echo "<td bgcolor='white' > <FONT COLOR='black' FACE='verdana' SIZE='2'> $data[$i] </font>  </td>  \n";
}

}
echo "</tr>\n";
}
echo "<table> \n"; 

}else 

{
echo '<font color="red"> error - missing id<br/> </font>';
}
oci_free_statement($stmt);
oci_close($conn);

?>

thanks for your help
I managed to improve

It would help to know the area you want to change to red.

As i had stated you would use an if statement nested into your existing loops. You will need to validate the data:

for example if $result4 == 'data'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.