这是我的代码..
<?php
$SupportingMaterialTaskSql = "select task_name,section_name,ref_student_id from scores where ref_student_id = '".$studentid."' and section_name = 'sm1' GROUP BY task_name ORDER BY cast( SUBSTRING( task_name, 5, 2 ) AS unsigned ) ASC";
$SupportingMaterialTaskResults = $obj->selectQuery($SupportingMaterialTaskSql);
if($SupportingMaterialTaskResults > 0)
{
foreach($SupportingMaterialTaskResults as $Key => $SupportingMaterialTaskRow)
{
$Task = $SupportingMaterialTaskRow['task_name'];
$str = "Task";
$TaskName = str_replace($str, "Task ", $Task);
?>
<tr>
<td width="30%" class="f13_blue cellbg"><?php echo $TaskName; ?></td>
</tr>
<?php
}
}
?>
这是此代码上方的输出..
Task2 Task3 Task5 Task6 Task7 Task8 Task9 Task10
所以我只想得到这样的结果。如果数据库具有像 Task1 这样的值,则打印 Task1,否则打印 Task1“N/A”。
那么我该如何解决呢?