gpt4 book ai didi

php - 所有单元格的背景颜色都是相同的

转载 作者:行者123 更新时间:2023-11-29 16:07:01 24 4
gpt4 key购买 nike

我正在为学生网创建学期 map 。如果正在学习类(class),单元格颜色应为黄色。如果类(class)被采用,应该是绿色的。如果类(class)尚未上完,单元格颜色将为红色。

我正在测试 ID 为“1”的学生,在表“course_status”中有一个名为“course_status”的列,其中仅包含“pending”、“in_progress”和“done”。

$sql = "SELECT * FROM course_status WHERE student_id = 1";
$retval = mysqli_query( $link, $sql );
$row=mysqli_fetch_array($retval);
if($row['course_status']== 'done') {$status_color = "green";}
if($row['course_status']== 'in_progress') {$status_color= "yellow";}
if($row['course_status']== 'pending') {$status_color= "red";}
<td style="background-color: <?php echo $status_color; ?>;">CSCI 185 
<td style="background-color: <?php echo $status_color; ?>;">CSCI 385
<td style="background-color: <?php echo $status_color; ?>;">CSCI 485

尽管学生尚未参加 CSCI 385 和 485,但所有单元格的背景颜色均为绿色。我只是希望 CSCI 185 自从被采用以来就有绿色背景。

最佳答案

尝试如下:

if($row['course_status']== 'done') {

<td style="background-color:green">something</td>//bg-color will be green

}else if($row['course_status']== 'in_progress'){

<td style="background-color:yellow">something</td>//bg-color will be yellow

} else {
<td style="background-color:red">something</td> //bg-color will be red

}

关于php - 所有单元格的背景颜色都是相同的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55643768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com