如何使用td id插入数据

时间:2018-03-02 20:41:49

标签: php html mysql

我的PHP代码如下。

public void doClickSpanForString(TextView txtSpan, String valtag, Integer valordtag) {
        spanText = new SpannableString(valtag+" ");
        MyClickableSpan a = new MyClickableSpan(valtag);
        a.setTag1(valtag);
        a.setTag2(valordtag);
        spanText.setSpan(a, 0, valtag.length(), 0);
        txtSpan.append(spanText);

    }

private class MyClickableSpan extends ClickableSpan {

        private String mtag1;
        private int mtag2;

        void setTag1(String tag) {
            mtag1 = tag;
        }
        String getTag1() {
            return mtag1;
        }
        void setTag2(Integer tag) {
            mtag2 = tag;
        }
        int getTag2() {
            return mtag2;
        }

        MyClickableSpan(String string) {
            super();
        }
        public void onClick(View tv) {
            //tv.performLongClick();


            setstr4val(getTag1());
            setint4valord(getTag2());

        }
}


我可以从数据库中获得考试成绩。但是我无法在标题下插入正确的数据。如果学生只是" 1.Project"结果,它显示在" 1.Exam"。如何在正确的标题下插入。谢谢..

1 个答案:

答案 0 :(得分:2)

如果没有结果与<td> <td>具有相同数量的<tr>,则必须创建空<tr > <td ><?php echo $ndsdersliste['es_subjectname']; ?></td> <?php $td = []; foreach ($myexamresults as $ndsmyexam) { $puan=""; if( $ndsdersliste['es_subjectname'] == $ndsmyexam['es_subjectname'] ) { $examname = $ndsmyexam['es_examname']; $puan = $ndsmyexam['es_puan']; if ($examname =="1.Exam") { $td['1E'] = $puan ; } if ($examname =="2.Exam") { $td['2E'] = $puan ; } if ($examname =="1.Project") { $td['1P'] = $puan ; } if ($examname =="2.Project") { $td['2P'] = $puan ; } } } if (isset($td['1E'])) echo '<td headers="1E">'.$td['1E'] .'</td>' ; else echo '<td headers="1E"></td>' ; if (isset($td['2E'])) echo '<td headers="2E">'.$td['2E'] .'</td>' ; else echo '<td headers="2E"></td>' ; if (isset($td['1P'])) echo '<td headers="1P">'.$td['1P'] .'</td>' ; else echo '<td headers="1P"></td>' ; if (isset($td['2P'])) echo '<td headers="2P">'.$td['2P'] .'</td>' ; else echo '<td headers="2P"></td>' ; ?> </tr>

error_page