I'm trying to edit this script to change color values for type_id
What I'm trying to do is when the table cell displays WTS it makes the bacground color of the row green, if it displays WTB then its red...etc. I had the values coded/edited like this: WTS,WTB, Other values are outputed from the file database.
[CODE] if ($value[6] == "WTS") { $colorclass = " class=\"green\""; }
elseif ($value[6] == "WTB") { $colorclass = " class=\"red\""; }
elseif ($value[6] == "Other") { $colorclass = " class=\"blue\""; }
else { $colorclass = " class=\"white\""; }
if ($key == 9 && $cellval == "") { $cellval = "anonymous"; }
echo "<td ".$colorclass.">".$cellval."</td>";[/CODE]
$value[6] is that value for type_id
$value[0] = $_POST['bug_id'];
$value[1] = str_replace($delimiter, " ", stripslashes(htmlentities($_POST['name'])));
$value[3] = $_POST['priority_id'];
$value[6] = $_POST['type_id'];
$value[8] = $_POST['status_id'];
$value[9] = $_POST['user_id'];
Whats happening is the script disregards all the if and elseif statements just outputs else only.
Here is the full php script:
<?php
$bugs_per_page = 100;
// keywords
if ($_SESSION['showclosed'] == "true" ) { $keyword = "status_id>=0"; } // all bugs
else { $keyword = "status_id<=4"; } // not closed
if (!empty($_GET['keyword'])) { $keyword .= ",keywords~=".$_GET['keyword']; }
// pages
$bug_record = OpenRecord("bug", "*", $keyword, "status_id num asc", "false");
if ($bugs_per_page > 0 && count($bug_record) > $bugs_per_page) {
$start = 0;
$page_num = 1;
if (!empty($_GET['page_num'])) { $page_num = $_GET['page_num']; }
$num_pages = intval(count($bug_record) / $bugs_per_page);
if ((count($bug_record) % $bugs_per_page) > 0) { $num_pages++; }
if ($page_num != 1) {
$start = (($page_num-1)*$bugs_per_page);
}
}
else { $num_pages = 0; }
echo "<div style='clear:both;'>";
echo "<br />";
echo "<table class=\"datatable\" width=\"100%\">";
echo "<caption>DEAL List";
if (!empty($_GET['keyword'])) { echo " <em>(keyword: ". $_GET['keyword'].")</em>"; }
echo "</caption>";
echo "<tr><th>DEAL ID</th><th>Type</th><th>Title</th><th>Priority</th><th>Submitter</th><th>Opened</th><th>Closed</th></tr>";
$record = OpenRecord("bug", "id,type_id,name,priority_id,user_id,opendate,closedate", $keyword, "id num desc", "true"); // list all bugs
if (!$record) {
echo "<tr><td colspan=\"12\">Empty</td></tr>";
}
else {
$start_count = 0;
$bug_count = 0;
foreach ($record as $current_record) {
if ($start_count >= $start && $bug_count < $bugs_per_page) {
$value = explode($delimiter, $current_record);
echo "<tr>";
$colorclass = "";
foreach ($value as $key => $cellval) {
$cellval = $cellval;
if ($key == 0) {
$cellval = "<a href=\"index.php?page=bug_show&bug_id=".$cellval."\">".$cellval."</a>"; // the bug id is clickable
}
if ($value[6] == "WTS") { $colorclass = " class=\"green\""; }
elseif ($value[6] == "WTB") { $colorclass = " class=\"red\""; }
elseif ($value[6] == "Other") { $colorclass = " class=\"blue\""; }
else { $colorclass = " class=\"white\""; }
if ($key == 9 && $cellval == "") { $cellval = "anonymous"; }
echo "<td ".$colorclass.">".$cellval."</td>";
}
echo "</tr>";
$bug_count++;
}
$start_count++;
}
}
echo "</table>";
// pages
if ($num_pages != 0) {
echo "<div align=\"center\">Pages: ";
for ($i = 1; $i <= $num_pages; $i++) {
if ($page_num == $i) { echo "<strong>[".$i."]</strong>"; }
else { echo "<a href=\"index.php?page=bug_list&showclosed=".$_SESSION['showclosed']."&keyword=".$_GET['keyword']."&page_num=".$i."\">[".$i."]</a>"; }
}
echo "</div>";
}
?>