1

基本的に、私は学生のスケジュールのデータベースを持っています。各クラス期間には、独自の列があります。特定の期間に特定のクラスを持つすべてのユーザーのすべての名前を返したいです。

これが私の現在のコードです。唯一の問題は、コードが最初の名前のみを返し、同じクラスの全員が返されるわけではないことです。

            if ($test_stmt=$mysqli->prepare("SELECT cps_schedules_userid FROM cps_schedules WHERE monday=?")) { //Get user's ids with same class in same period
                $test_stmt->bind_param('s',$classarray_withperiod[$i]); //Bind parameters (class name)
                $test_stmt->execute(); //Execute the prepared query
                $test_stmt->store_result(); //Store result
                if ($test_stmt->num_rows()<=1) { //0 or 1 rows were returned, meaning that only the current user has this class
                }
                else { //Other people have the class, so the query returned values
                    $entirerowdata = array(); //Create array to hold all data in returned row
                    stmt_bind_assoc($test_stmt, $entirerowdata); //Get all values in row
                    $arrayofusernames=array(); //Create array to hold names of all the users
                    $arrayofusernamesindex=0;
                    while ($test_stmt->fetch()) {
                        //Convert userid -> username
                        $arrayofusernames[$arrayofusernamesindex]=$entirerowdata['cps_members_username'];
                        $arrayofusernamesindex++;
                    }
                }
            }

これは私の cps_schedules データベースのスナップショットです。基本的に、「friday7」に達するまで右に進みます。

データベースのスナップショット

4

0 に答える 0