What I want is show the total clicks per Category id of the items only for 20 items order by the highest total clicks per day.
Now I am using hard code and the result have to looks like this
So, if the item id and total clicks already fill up the
20columns (for item id and total clicks) + 2 for the tittle so means
22columns
It has to move to next row.
Because I am referring to my db, so I am using loop to create the table, and when I doing that way, I am getting this result....
The result will keep showing until the end in the left side. Thats very hard to read for report purposes. I wanted the result looks like the first figure that I've uploaded.
Here is what I am doing now:
include "Con.php";
//get the value from Get Method
$CatidValue = $_GET['CatIds'];
//(The date format would looks like yyyy-mm-dd)
$DateFrom = $_GET['DateFrom'];
$DateTo = $_GET['DateTo'];
//select the CatID
$SqlGet= "Select CatId from try where CatId = $CatidValue";
$_SqlGet = mysqli_query($connection,$SqlGet);
$TakeResultGet = mysqli_fetch_array($_SqlGet);
$CatIdTittle = $TakeResultGet ['CatId'];
echo"
For Category Id : $CatIdTittle
<br>
";
//For Loop purpose and break the value
$explodeValueFrom = explode("-",$DateFrom);
$explodeValueTo = explode("-",$DateTo);
$DateValueFrom = $explodeValueFrom[0].$explodeValueFrom[1].$explodeValueFrom[2];
$DateValueTo = $explodeValueTo[0].$explodeValueTo[1].$explodeValueTo[2];
//Loop through the date
for($Loop=$DateValueFrom; $Loop <= $DateValueTo; $Loop++){
$YearLoop= substr($Loop, 0,4);
$MonthLoop =substr($Loop, 4,2);
$DayLoop = substr($Loop, 6,2);
$DateTittleValue = $YearLoop."-".$MonthLoop."-".$DayLoop;
$trValue = "<th class='tg-amwm' colspan='2'>$DateTittleValue</th>";
echo"
<table class='tg'>
<tr>
$trValue
</tr>
";
echo"
<table class='tg'>
<tr>
<td class='tg-yw4l'>Items Id</td>
<td class='tg-yw4l'>Total Clicks</td>
</tr>
";
//to get the item id and total clicks
$SqlSelect = "select `Item Id`,`Total Clicks`,Day from try where CatId = $CatidValue and Day = '$DateTittleValue' ORDER BY `try`.`Total Clicks` DESC limit 20";
$_SqlSelect = mysqli_query($connection,$SqlSelect);
foreach ($_SqlSelect as $ResultSelect) {
$Day = $ResultSelect['Day'];
$ItemId = $ResultSelect['Item Id'];
$TotalClicks = $ResultSelect['Total Clicks'];
echo"
<tr>
<td class='tg-yw4l'>$ItemId</td>
<td class='tg-yw4l'>$TotalClicks</td>
</tr>
";
}
}
?>
you need to add td dynamically within a table for each day report ( data should be grouped by date).
You just need to float each table with the float:left css property and some percentage based on the number of tables you want on the same row. In this case, 33% will do. Take a look at this codepen: http://codepen.io/anon/pen/EgXqPk
The magic happens on:
.tg {
width: 33%;
float:left;
}
you can try i hope this perfect for you to draw a table using PHP Loop.
<?php
echo "<table border =\"1\" style='border-collapse: collapse'>";
for ($row=1; $row <= 10; $row++) {
echo "<tr> \n";
for ($col=1; $col <= 10; $col++) {
$p = $col * $row;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
Related
so, what i wanted to do is show the total clicks per Category id of the items only for 20 items order by the highest total clicks per day.
now i am using hard code and the result have to looks like this
so, if the item id and total clicks already fill up the
20columns (for item id and total clicks) + 2 for the tittle so means
22columns
it has to move to next row.
because i am reffering to my db, so i am using loop to create the table, and when i doing that way, i am getting this result....
the result will keep showing until the end in the left side. thats very hard to read for report purposes. so i wanted the result looks like the first figure that i've uploaded.
here is what i am doing now
include "Con.php";
//get the value from Get Method
$CatidValue = $_GET['CatIds'];
//(The date format would looks like yyyy-mm-dd)
$DateFrom = $_GET['DateFrom'];
$DateTo = $_GET['DateTo'];
//select the CatID
$SqlGet= "Select CatId from try where CatId = $CatidValue";
$_SqlGet = mysqli_query($connection,$SqlGet);
$TakeResultGet = mysqli_fetch_array($_SqlGet);
$CatIdTittle = $TakeResultGet ['CatId'];
echo"
For Category Id : $CatIdTittle
<br>
";
//For Loop purpose and break the value
$explodeValueFrom = explode("-",$DateFrom);
$explodeValueTo = explode("-",$DateTo);
$DateValueFrom = $explodeValueFrom[0].$explodeValueFrom[1].$explodeValueFrom[2];
$DateValueTo = $explodeValueTo[0].$explodeValueTo[1].$explodeValueTo[2];
//Loop through the date
for($Loop=$DateValueFrom; $Loop <= $DateValueTo; $Loop++){
$YearLoop= substr($Loop, 0,4);
$MonthLoop =substr($Loop, 4,2);
$DayLoop = substr($Loop, 6,2);
$DateTittleValue = $YearLoop."-".$MonthLoop."-".$DayLoop;
$trValue = "<th class='tg-amwm' colspan='2'>$DateTittleValue</th>";
echo"
<table class='tg'>
<tr>
$trValue
</tr>
";
echo"
<table class='tg'>
<tr>
<td class='tg-yw4l'>Items Id</td>
<td class='tg-yw4l'>Total Clicks</td>
</tr>
";
//to get the item id and total clicks
$SqlSelect = "select `Item Id`,`Total Clicks`,Day from try where CatId = $CatidValue and Day = '$DateTittleValue' ORDER BY `try`.`Total Clicks` DESC limit 20";
$_SqlSelect = mysqli_query($connection,$SqlSelect);
foreach ($_SqlSelect as $ResultSelect) {
$Day = $ResultSelect['Day'];
$ItemId = $ResultSelect['Item Id'];
$TotalClicks = $ResultSelect['Total Clicks'];
echo"
<tr>
<td class='tg-yw4l'>$ItemId</td>
<td class='tg-yw4l'>$TotalClicks</td>
</tr>
";
}
}
?>
You dont need to declare your trValueTitle in the loop. Plus you need to concatenate it in your echo, try this :
$trValueTittle ="1"."<th class='tg-amwm' colspan='2'>$DateTittleValue</th>" ;
echo"<table class='tg'>";
for($loopForTr=1; $loopForTr<=3; $loopForTr++){
echo"<tr>". $trValueTittle ."</tr>";
}
I don't know what you want to do with the "1", but I think this is what you want to do:
echo "<table class='tg'>";
for($loopForTr=1; $loopForTr<=3; $loopForTr++){
$trValueTittle ="<th class='tg-amwm' colspan='2'>$DateTittleValue</th>";
echo"
<tr>
$trValueTittle
</tr>";
}
echo "</table>";
$trValueTittle ="1"."<th class='tg-amwm' colspan='2'>$DateTittleValue</th>" ;
echo"<table class='tg'>
<thead>
<tr>";
for($loopForTr=1; $loopForTr<=3; $loopForTr++){
echo $trValueTittle;
}
echo"</tr>
</thead>
</table>";
#Mantello, good answer, but i think it's better to keep out the "tr" from the loop, cause usually you don't want to place your tableheads (th) in different rows.
#Rax your Code won't work. You'll recive an error. You can't output a Variable the way you did in your echo.
echo"<tr> '.$trValueTittle.' </tr>";
would be fine. But there's also no need to define your variable inside the for loop. This way you slow up your script.
The code below has dynamic drop down list, that users chooses preferred brand and model, accordingly the table is generated in the webpage which results of brand, model and year . Now the code needs to group all the same year with different models and highlight them with set of different colors for each year accordingly. An expected results is attached as image.
// (___ & !!!) or (ALL & ___) or (ALL & ALL)
if ((!isset($_POST['model']) || ($_POST['brand'] == 'ALL' && empty($_POST['model']))) || ($_POST['brand'] == 'ALL' && $_POST['sip'] == 'ALL')) {
$query1 = 'SELECT DISTINCT brand,model,year FROM `carlist` ORDER BY brand,model,year';
}
// (... & ...) or (... & ALL)
else if (!empty($_POST['brand']) && (empty($_POST['model']) || ($_POST['model'] == 'ALL'))) {
$query1 = 'SELECT DISTINCT brand,model,year FROM `carlist` WHERE brand="'.$_POST['brand'].'" ORDER BY brand,model,year';
}
// (ALL & ...) or (ALL & notALL)
else if ($_POST['brand'] == 'ALL' && (!empty($_POST['model']) && $_POST['model'] != 'ALL')) {
$query1 = 'SELECT DISTINCT brand,model,year FROM `carlist` WHERE model="'.$_POST['model'].'" ORDER BY brand,model,year';
}
else {
$query1 = 'SELECT DISTINCT brand,model,year FROM `carlist` WHERE brand="'.$_POST['brand'].'" AND model="'.$_POST['model'].'" ORDER BY brand,model,year';
}
//echo $_POST['brand'].'<br />'.$_POST['model'];
echo '<table border=1><tr><th>BRAND</th><th>MODEL</th><th>YEAR</th></tr>';
$result1 = mysqli_query($con, $query1);
while($row1 = mysqli_fetch_array($result1)){
//echo'<tr><td>'.$row1['brand'].'</td><td>'.$row1['model'].'</td><td>'.$row1['year'].'</td></tr>';
$query2= 'SELECT DISTINCT brand,model,year, count(*) `number` FROM `carlist` WHERE brand="'.$_POST['brand'].'" GROUP BY `year` HAVING count(*) > 1';
$result2= mysqli_query($con, $query2);
$count=0;
while($row2 = mysqli_fetch_array($result2)){
if ( $row2['year'] == $row1['year']) {
$count=1;
}
//$intersect = array_intersect($row1,$row2);
//echo $intersect[1];
}
$bgcolor = "#FF8C00";
if($count==1){
echo '<tr style="background-color: tomato;" ><td>'.$row1['brand'].'</td><td>'.$row1['model'].'</td><td>'.$row1['year'].'</td></tr>';
}else {
echo'<tr><td>'.$row1['brand'].'</td><td>'.$row1['model'].'</td><td>'.$row1['year'].'</td></tr>';
}
}
echo '</table>';
Create function what generates random color
function getColor($year){
return '#'.substr(md5($year), 0, 6);
}
In your while loop
// Get color for current year
// Same years will be colored with same color
$bgColor = getColor($row1['year']);
// Print table row
echo '<tr style="background-color: '.$bgColor.';"><td>'.$row1['brand'].'</td><td>'.$row1['model'].'</td><td>'.$row1['year'].'</td></tr>';
So your while loop will be
while($row1 = mysqli_fetch_array($result1)){
// Delete extra while and if condition
$bgColor = getColor($row1['year']);
echo '<tr style="background-color: '.$bgColor.';"><td>'.$row1['brand'].'</td><td>'.$row1['model'].'</td><td>'.$row1['year'].'</td></tr>';
}
NOTE: Your queries are vulnerable to SQL injection. Please see this answer on how to prevent it.
NOTE 2: Since your background colors are generated automatically, it may happen that text is not easily readable.
Method 1:
This won't need to do a nested loop. This first method will only work if your row is arranged by year.
/* DEFINE THIS VARIABLE FIRST BEFORE YOUR LOOP */
$yearstorage = ""; /* STORAGE FOR YOUR YEAR AND COMPARISON LATER */
$randomcolor = '#' . strtoupper(dechex(rand(256,16777215))); /* GENERATE RANDOM COLOR */
/* START OF YOUR LOOP */
while($row1 = mysqli_fetch_array($result1)){
$res = mysqli_query($con,"SELECT * FROM carlist WHERE year=".$row1['year']."");
if(mysqli_num_rows($res) > 1){ /* IF YEAR HAS ONLY ONE ROW */
$randomcolor = "#ffffff";
}
if(empty($yearstorage)){ /* START OF FIRST ROW */
?>
<tr style="background-color: <?php echo $randomcolor ?>;">
<?php
$storecolor = $randomcolor;
}
else if($yearstorage == $row1["year"]){ /* IF LAST YEAR ROW IS THE SAME AS THE CURRENT YEAR ROW */
?>
<tr style="background-color: <?php echo $storecolor ?>;">
<?php
}
else { /* IF THE LAST YEAR ROW IS NOT THE SAME WITH THE CURRENT YEAR ROW */
$randomcolor = '#' . strtoupper(dechex(rand(256,16777215))); /* GENERATE NEW RANDOM COLOR */
?>
<tr style="background-color: <?php echo $randomcolor ?>;">
<?php
$storecolor = $randomcolor;
}
$yearstorage = $row1["year"]; /* STORE THE CURRENT YEAR FOR COMPARISON ON THE NEXT LOOP */
?>
<td><?php echo $row1['brand']; ?></td>
<td><?php echo $row1['model']; ?></td>
<td><?php echo $row1['year']; ?></td>
</tr>
<?php
} /* END OF WHILE LOOP */
Method 2:
This second method will work even if your row is not arrange in year. Even if arranged by different column name which I would refer more to you.
You have to create a loop to get all the year distinctly, and store the color and year in an array, and compare and get them on your main loop.
No need to do a nested loop also. But two separated loop.
As you will notice, this code is also shorter than the first method.
If a year contains one row only, it will have a white background.
$counter = 0; /* DETERMINER OF THE COLOR TO BE USED LATER */
$res = mysqli_query($con,"SELECT DISTINCT year FROM carlist");
while($row = mysqli_fetch_array($res)){
$randomcolor = '#' . strtoupper(dechex(rand(256,16777215))); /* GENERATE NEW RANDOM COLOR */
/* STORE THE COLOR AND YEAR IN AN ARRAY */
$res2 = mysqli_query($con,"SELECT * FROM carlist WHERE year = ".$row['year']."");
if(mysqli_num_rows($res2) > 1){ /* IF YEAR IS USED MORE THAN ONCE */
$colorstorage[$counter] = $randomcolor;
}
else { /* ELSE, IT WILL HAVE A WHITE BACKGROUND */
$colorstorage[$counter] = "#ffffff";
}
$yearstorage[$counter] = $row['year'];
$counter = $counter + 1; /* INCREMENT COUNTER */
} /* END OF LOOP THAT STORES THE COLOR AND YEAR IN AN ARRAY */
/* START OF YOUR MAIN LOOP */
while($row1 = mysqli_fetch_array($result1)){
$key = array_search($row1["year"],$yearstorage);
?>
<tr style="background-color: <?php echo $colorstorage[$key]; ?>;">
<td><?php echo $row1['brand']; ?></td>
<td><?php echo $row1['model']; ?></td>
<td><?php echo $row1['year']; ?></td>
</tr>
<?php
} /* END OF YOUR MAIN LOOP */
So I have this code setup to display food entries by expiration dates on a table, from top to bottom, earliest to latest. If they are within three days of the current date, the text will be yellow,if it is anytime after that, the text will be red.
Anyway, I recently was testing and realized that if two entries have the same date, the way I have my code setup, it would pull show only one of the entries however number of times that expiration date is on the table (the very first entry with that date added to be exact).
So I setup a for loop uses some queries to check if there were more than one entries and then displayed each one subsequently. Problem is, I get to the final index for the loop, and the Name associated with that date will not show up. Heres the Code:
<?php
$sql1=mysql_query("SELECT email from loggedin WHERE session_id='$userid'");
$sess=mysql_fetch_array($sql1);
$newValue=$sess['email'];
$sqlLength = mysql_query("SELECT * FROM food WHERE OwnerEmail='$newValue'");
?>
<div class="table-responsive">
<h2 class="sub-header">Expiration Dates</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Food Name</th>
<th>Brand Name</th>
<th>Food Group</th>
<th>Location</th>
<th>Expiration Date</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
while($test = mysql_fetch_array($sqlLength)){
$dates[$i] = $test['ExpirationDate'];
$i++;
}
$length=count($dates);
for($x=0;$x<$length;$x++){
$year[$x]=substr($dates[$x],6,4);
$month[$x] = substr($dates[$x],3,2);
$day[$x] = substr($dates[$x],0,2);
}
for($x=0;$x<$length-1;$x++){
for($y=$x+1;$y<$length;$y++){
if($year[$x] > $year[$y]){
$temp=$year[$x];
$year[$x]= $year[$y];
$year[$y]=$temp;
$temp=$month[$x];
$month[$x]= $month[$y];
$month[$y]=$temp;
$temp=$day[$x];
$day[$x] = $day[$y];
$day[$y] = $temp;
}
elseif($year[$x] == $year[$y]){
if($month[$x] > $month[$y]){
$temp=$month[$x];
$month[$x]= $month[$y];
$month[$y]=$temp;
$temp=$day[$x];
$day[$x] = $day[$y];
$day[$y] = $temp;
}
elseif($month[$x] == $month[$y]){
if($day[$x] > $day[$y]){
$temp=$day[$x];
$day[$x] = $day[$y];
$day[$y] = $temp;
}
}
}
}
}
for($x=0;$x<$length;$x++){
$orderedDates[$x]= "$day[$x]-$month[$x]-$year[$x]";
}
$currentYear=date("Y");
$currentMonth=date("m");
$currentDay=date("d");
$multiple="false";
for($x=0;$x<$length;$x++){
$class='';
if($multiple=="false"){
$sql2 = mysql_query("SELECT * FROM food WHERE OwnerEmail='$newValue' AND ExpirationDate='$orderedDates[$x]'") or die(mysql_error());
$rows = mysql_fetch_array($sql2);
if(count($rows) > 7){
$y=1;
$multiple="true";
$count=count($rows)/7;
}
}
else{
$rows = mysql_fetch_array($sql2);
$y++;
//$x++;
}
$year=substr($rows['ExpirationDate'],6,4);
$month=substr($rows['ExpirationDate'],3,2);
$day=substr($rows['ExpirationDate'],0,2);
if($year==$currentYear){
if($month==$currentMonth){
if(($day - $currentDay) <= 3){
$class='expBad';
}
}
}
if($currentYear > $year){
$class='expGross';
}
elseif($currentYear == $year){
if($currentMonth > $month){
$class = 'expGross';
}
elseif($currentMonth == $month){
if($currentDay > $day){
$class='expGross';
}
}
}
?>
<tr>
<td><b><?php echo $rows['Name'] ?></td>
<td><b><?php echo $rows['Brand'] ?></td>
<td><b><?php echo $rows['Type'] ?></td>
<td><b><?php echo $rows['Container'] ?></td>
<td><b><?php echo "<span class=\"$class\">".$rows['ExpirationDate']."</span>" ?></td>
</tr>
<?php
if($y == $count){
$multiple="false";
}
}
/*
$er=mysql_query("SELECT Name FROM food WHERE ExpirationDate='$orderedDates[3]'");
$der = mysql_fetch_array($er);
$mer=$der['Name'];
echo $mer;
*/
?>
</tbody>
</table>
Some info to know, my food table has 7 columns.
orderedDates gives me a correctly ordered array (I know there's a better way to do that, but I was just starting php when I wrote that)
There are 4 food entries.
Here's the problem, when I get to $x = 3, for some reason it does not display any of the column values for that entry.
Here are what the entries should look like in the table.
what s Grains Pantry 12-02-2012
why s Grains Pantry 12-02-2012
who s Grains Pantry 08-04-2014
where s Grains Pantry 10-04-2014
I only get the first 3 entries and then the 4th row is empty.
the other two columns are id and OwnerEmail
It turns out the count() function was returning back a number other than what I thought.
Which is I thought $count would equal 1 for the value that had a unique expiration date.
But instead it was 2, which caused it to run the mysql_fetch_array function one more time than I wanted,making it point at a null value;
instead I used the following code to get the number of food items with same dates:
$sql2 = mysql_query("SELECT Name FROM food WHERE OwnerEmail='$emailname' AND ExpirationDate='$orderedDates[$x]'") or die(mysql_error());
$count2=0;
while($rows2 = mysql_fetch_array($sql2)){
$count2++;
}
I've been to this site several times before for help which I've managed to solve problems encountered in the past but this time I think I'm going to actually have to ask my own question.
I am working on a system in which employees of a small company can put in their appointments they had every week of the month, including the appointments, number of sales and amount of money made from them. I already calculated things like the success percentage and everything.
Now here lies the problem:
I need to make it so that the week numbers are automatically calculated rather than just put in 5 weeks a month.(Currently it works like: January 1-5 February 5 - 10 and so forth) And the numbers need to be linked to a page where the user can edit the information of that week.
I already know how to make a page like this too, the only thing I really need help with is finding out how to best put the week numbers in properly. (Security not being really an issue because it runs on an internal web server.)
Here's the table segment of my calendar.php :
<table id='myTable' width="600" border="1" cellspacing="3">
<tr>
<th align="left">
Prev </th>
<th colspan='3' width="200"><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></th>
<th align="right"> Next </th></tr>
<?php
echo "<tr align='center'>";
//Rather than a loop, need to get the amount of weeks in each month.
$startingMonthWeekNum = ((($cMonth-1)*5)+1);
$endingMonthWeekNum = ($cMonth*5+1);
echo "<tr><th>Week #</th><th>Afspraken</th><th>Sales</th><th>Omzet</th><th>Conversie %</th></tr>";
for($i = $startingMonthWeekNum; $i < $endingMonthWeekNum; $i++)
{
//Reset variables
$appointments = null;
$sales = null;
$revenue = null;
$conversie = null;
$result = mysqli_query($con, "SELECT * FROM cms_appointments where date_week = $i and date_year = $cYear and id_user = $userId group by date_week");
$sumAppointments = 0;
$sumSales = 0;
$sumRevenue = 0;
while($row = mysqli_fetch_array($result))
{
$weekRow = $row['date_week'];
$appointments = $row['appointments'];
$sales = $row['sales'];
$revenue = $row['revenue'];
$conversie = $appointments > 0 ? ($sales / $appointments)*100 : 0;
}
$sumAppointments += $appointments;
$sumSales += $sales;
$sumRevenue += $revenue;
echo "<tr align='center'>";
echo "<td>$i</td><td>$appointments</td><td>$sales</td><td>$revenue</td><td>$conversie</td>";
echo "</tr>";
}
echo "<tr align='center'><td>Total</td><td>$sumAppointments</td><td>$sumSales</td><td>$sumRevenue</td><td>".($sumAppointments > 0 ? ($sumSales / $sumAppointments)*100 : 0)."</td></tr>";
echo "</tr> </table>";
mysqli_close($con);
?>
I have a small database behind this with the table cms_appointments having all the information in them which are used in this code. The appointments, sales and revenue.
This is the first time I posted a question and if it can be improved in some way, I will try my best to make it easier as this site helped me out greatly in the past, I want to leave this as a well explained first question.
I've been searching and searching for this answer, but either I'm not understanding it completely (probable as I'm new to php) or I can't get the right answer.
I have one php page that pulls in information from my sql table that has many different columns. This is the code......
$sql = "SELECT * FROM 2012_TNAfigures ORDER BY id DESC";
$query = mysql_query($sql) or die(mysql_error());
echo "<table class='tableDressing' id='2012table'><tbody>";
while ($row = mysql_fetch_array($query)){
$render2012 = "<tr><td class='cellDressing'>".$row['weekday']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['day']."</td>
<td class='cellDressing'>".$row['price']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td class='cellDressing'>".$row['month']."</td>
<td style=\"color: $openColor\">".$row['open']."</td>
<td class='cellDressing'>".$row['close']."</td>
<td class='cellDressing'>".$row['high']."</td>
<td class='cellDressing'>".$row['low']."</td>
<td class='cellDressing'>".$row['changePercentage']."</td>
<td class='cellDressing'>".$row['volume']."</td></tr>";
echo $render2012;
}
When that pulls the numbers in, the columns will each have different numbers that I need to apply color changes depending on the values in that cell. Here is what I've created for making the color changes....
if (($row >= 1) && ($row <= 46))
$openColor = $red;
else if (($row >= 46.01) && ($row <= 60))
$openColor = $green;
As you can see, $row doesn't work. What I don't know how to do is pull in a column, say "open", verify the value of that column in my function and then have that determine which color to use. There will be many rows thrown out for each column as well, with changing values. I assume I need to assign that column to a variable, then parse that variable through the function, but I can't seem to figure it out.
Thanks to everyone in advance. Let me know if I should supply more information.
$row in it self is an array. You can't test an array with a number.
if (($row['your_number'] >= 1) && ($row['your_number'] <= 46)) {
// Do your action
}
if (($row >= 1) && ($row <= 46))
$openColor = 'Red';
else if (($row >= 46.01) && ($row <= 60))
$openColor = 'Green';
add to your td class name like this
<td class="td<?php echo $openColor; ?>" >table cell data</td>
in your css stylesheet file assign the colour values you want. I've used descriptive names here but change these to the hex colour codes you want.
.tdGreen{
background-color: green;
}
.tdRed {
background-color: red;
}