循环打印数组数据时遇到非数值

时间:2019-04-24 15:20:08

标签: php select mysqli printing

截至目前,我在遍历数据库中的字符串变量并打印它们时遇到了问题。我对PHP还是很陌生,并且正在尝试解决这个问题,朝着正确方向的任何指导都是很棒的。

$ result = $ conn-> query(“ SELECT * FROM score WHERE Teacheremail ='$ questionemail'and gameid ='$ gameid'”);

     if ( $result->num_rows == 0 ){ // User doesn't exist
            echo "There are no questions associated with that email or game!";
            die();
    }

        else{  

            while($row = mysqli_fetch_assoc($result))
              {
               $playeremail[] = $row['gameemail'];
               $scores[] = $row['score'];
               $question1[] = $row['question1'];
               $question2[] = $row['question2'];
               $question3[] = $row['question3'];
               $question4[] = $row['question4'];
               $question5[] = $row['question5'];
               $question6[] = $row['question6'];
               $question7[] = $row['question7'];
               $question8[] = $row['question8'];
               $question9[] = $row['question9'];
               $question10[] = $row['question10'];
             }

              $length = $result->num_rows;
                for ($i = 0; $i <= $length; $i++) {
                print "Player Email: " + $playeremail[$i] + " Player Score: " + $scores[$i];
                print "Question 1 Results: " + $question1[$i];
                print "Question 2 Results: " + $question2[$i];
                print "Question 3 Results: " + $question3[$i];
                print "Question 4 Results: " + $question4[$i];
                print "Question 5 Results: " + $question5[$i];
                print "Question 6 Results: " + $question6[$i];
                print "Question 7 Results: " + $question7[$i];
                print "Question 8 Results: " + $question8[$i];
                print "Question 9 Results: " + $question9[$i];
                print "Question 10 Results: " + $question10[$i];
                }           
        }

0 个答案:

没有答案