0

Here is the code. I am trying to hi-lite rows that are generated that have a value of "Y" for column AA_letter_recd in yellow, the rows . The ones that have a value of "N" are not to be high-lited in yellow. Thanks.

<?php
/*Main Store Index */ 
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
$db_host = "xxx"; 
$db_username = "xxx";  
$db_pass = "xxx";   
$db_name = "xxx";   

mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database exists");  

// Run a select query to get my all (*) items from master list
//dynamic list is an empty string. depends on other factors

$examsdynamicList = "";

$sql = mysql_query("SELECT * FROM exams ORDER BY Exam_date");
$fileCount = mysql_num_rows($sql); // count the output amount
if ($filecount > 0) {

/*get all the matter details*/

while($row = mysql_fetch_array($sql)){

$id = $row["id"];
$File_no = $row["File_no"];
$EE_name = $row["EE_name"];
$Doctor = $row["Doctor"];
$Exam_date = $row["Exam_date"];
$Appointment_letter_date = $row["Appointment_letter_date"];
$Joint_letter_sent_date = $row["Joint_letter_sent_date"];
$Sent_to_doctor_date = $row["Sent_to_doctor_date"];
$Type = $row["Type"];
$Notes1 = $row["Notes1"];
$Notes2 = $row["Notes2"];
$Notes3 = $row["Notes3"];
$AA_letter_recd = $row["AA_letter_recd"];

if ($AA_letter_recd == "Y")

$examsdynamicList .= '

<tr style="background-color: Yellow;">
    <td>' . $EE_name . '</td>
    <td>' . $File_no . '</td>
    <td>' . $Doctor . '</td>
    <td>' . $Exam_date . '</td>
    <td>' . $Appointment_letter_date . '</td>
    <td>' . $Joint_letter_sent_date . '</td>
    <td>' . $Sent_to_doctor_date . '</td>
    <td>' . $Type . '</td>
    <td>' . $Notes1 . '</td>
    <td>' . $Notes2 . '</td>
    <td>' . $Notes3 . '</td>
    <td>' . $AA_letter_recd . '</td>
    </tr>

';


if ($AA_letter_recd == "N")

$examsdynamicList .= '

<tr>
    <td>' . $EE_name . '</td>
    <td>' . $File_no . '</td>
    <td>' . $Doctor . '</td>
    <td>' . $Exam_date . '</td>
    <td>' . $Appointment_letter_date . '</td>
    <td>' . $Joint_letter_sent_date . '</td>
    <td>' . $Sent_to_doctor_date . '</td>
    <td>' . $Type . '</td>
    <td>' . $Notes1 . '</td>
    <td>' . $Notes2 . '</td>
    <td>' . $Notes3 . '</td>
    <td>' . $AA_letter_recd . '</td>
    </tr>

';


}


} else {
    $examsdynamicList = "Sorry! Master List is Unavailable. Please try again later.";
}
mysql_close();
?>

Edited by codephp: Sorry, I cahnged the wording so you would better understand. it didnt make sense.

3
Contributors
6
Replies
32
Views
3 Years
Discussion Span
Last Post by codephp
1

No need for 41-82.

$class = ($AA_letter_recd == "Y") ? ' class="highlight"' : '';
$examsdynamicList .= '
<tr'.$class.'>
    <td>' . $EE_name . '</td>
    <td>' . $File_no . '</td>
    <td>' . $Doctor . '</td>
    <td>' . $Exam_date . '</td>
    <td>' . $Appointment_letter_date . '</td>
    <td>' . $Joint_letter_sent_date . '</td>
    <td>' . $Sent_to_doctor_date . '</td>
    <td>' . $Type . '</td>
    <td>' . $Notes1 . '</td>
    <td>' . $Notes2 . '</td>
    <td>' . $Notes3 . '</td>
    <td>' . $AA_letter_recd . '</td>
    </tr>
';

Then in your css:

.highlight
{
    background-color: yellow; //use the hex value though
}

Edited by diafol

0

Thank you. But the CSS you instruct..Doesn't that just make all rows yellow? I want rows with a value "Y" pulled from MySQL database to be high-lited yellow on the output .php webpage. In turn, I want the rows pulled with value "N" (This is for $AA_letter_recd) to not be high-lited.

0

Sorry, I glossed over the part where you added the $class stuff. Yes, I tried.

I did add the class to css too. Here is the code i have now:

<?php
/*Main Store Index */ 
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
$db_host = "xxx"; 
$db_username = "xxx";  
$db_pass = "xxx";   
$db_name = "xxx";   

mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database exists");  

// Run a select query to get my all (*) items from master list
//dynamic list is an empty string. depends on other factors

$examsdynamicList = "";

$sql = mysql_query("SELECT * FROM exams ORDER BY EE_name");
$fileCount = mysql_num_rows($sql); // count the output amount
if ($fileCount > 0) {

/*get all the matter details*/

while($row = mysql_fetch_array($sql)){

$id = $row["id"];
$Doctor = $row["Doctor"];
$File_no = $row["File_no"];
$EE_name = $row["EE_name"];
$Exam_date = $row["Exam_date"];
$Appointment_letter_date = $row["Appointment_letter_date"];
$Joint_letter_sent_date = $row["Joint_letter_sent_date"];
$Sent_to_doctor_date = $row["Sent_to_doctor_date"];
$Type = $row["Type"];
$Notes1 = $row["Notes1"];
$Notes2 = $row["Notes2"];
$Notes3 = $row["Notes3"];
$AA_letter_recd = $row["AA_letter_recd"];
$class = ($AA_letter_recd == "Y") ? ' class="highlight"' : '';
$examsdynamicList .= '
<tr'.$class.'>
    <td>' . $EE_name . '</td>
    <td>' . $File_no . '</td>
    <td>' . $Doctor . '</td>
    <td>' . $Exam_date . '</td>
    <td>' . $Appointment_letter_date . '</td>
    <td>' . $Joint_letter_sent_date . '</td>
    <td>' . $Sent_to_doctor_date . '</td>
    <td>' . $Type . '</td>
    <td>' . $Notes1 . '</td>
    <td>' . $Notes2 . '</td>
    <td>' . $Notes3 . '</td>
    <td>' . $AA_letter_recd . '</td>
    </tr>
'';}

} else {
    $examsdynamicList = "Sorry! Master List is Unavailable. Please try again later.";
}
mysql_close();
?>

the list is being populated, but the color assigned in CSS is not being applied to the rows with value Y. I had an earlier syntax error here, but I fixed it. It was an extra "'"

Thank you.

Edited by codephp: had an error listed that i fixed already

0

Solved, I had a script running defining table styles in another php file. Thank you!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.