
gmc1103
Members-
Posts
258 -
Joined
-
Last visited
gmc1103's Achievements
-
Hello again Iv'e been checking php functions to check the result when i use this $result = $stmt->fetchAll(PDO::FETCH_ASSOC); And one of function is sizeof $result = $stmt->fetchAll(PDO::FETCH_ASSOC); //echo json_encode(getDadosVisita($result)); echo sizeof($result); For one supervisor the echo is 154[] And for another supervisor is 154 So now i'm lost...what's is going on to have [] in supervisor and none in another?
-
Hello agian Sendin the file with 2 dumps json_encode start at line 11579 The website don't allow me to put with code tags But it seems it is the json_encode who is adding [] ate the end. data.txt
-
Hello, thanks for participating Are the teachers and supervisors saved as an Array in the database? No We have 4 supervisors, each one have same access rights and can see the same stuffs. In this case, 2 supervisors who wants to check all study visits use this query. But as you can the final [] in one gives no data.
-
Hello, thanks for your answer. The var_dump shows [] at the end in one supervisor and without [] in another one supervisor...i don't see why. The images posted are the var_dump result. Thanks
-
Hello I'm having problems regardind the result of a query using PDO, my site have 2 different access, teacher and supervisor. Two supervisors have the same access but one show result and the other one no because of those "[]" $stmt = $DB_con->prepare("SELECT v.idVisita, e.Escola, p.Nome, t.Turma, v.TipoTurma, v.Destino, v.StartDate, v.EndDate, v.TipoTransporte, vt.alunosVisita, vt.idTurma as idTurma, v.TotalAluno, v.PdfVisita, v.Avaliacao, v.idProfessor, v.Saida, v.Chegada, v.PlanoOcupacaoAlunos, v.PlanoOcupacaoTurmas, v.CustoEstadia, v.CustoSeguro, v.CustoTransporte, v.TipoSeguro, v.TipoEstadia, v.TipoTransporte, v.idProfessor, v.Obs, v.Areas, v.Total, v.TipoEstadia, v.TipoSeguro, v.TipoTransporte, v.Financiamento, vt.idTurma, v.PdfAvaliacao, v.Estado, IF(v.Estado='1','DEF',IF(v.Estado='0','IND','AG')) as EstadoNum, v.CustoIngressos, v.TipoIngressos, v.haveClasses, d.Departamento, v.percent FROM visitas AS v INNER JOIN escolas AS e ON (v.idEscola = e.idEscola) INNER JOIN visitasturmas AS vt ON (v.idVisita = vt.idVisita) INNER JOIN turmas AS t ON (vt.idTurma = t.idTurma) INNER JOIN professores AS p ON (v.idProfessor = p.idProfessor) INNER JOIN anosescolares AS ae ON (vt.idAnoEscolar = ae.idAnoEscolar) INNER JOIN grupos g on p.idGrupo = g.idGrupo INNER JOIN departamentos d on g.idDepartamento = d.idDepartamento WHERE ae.Estado = 1 ORDER BY v.idVisita,v.StartDate, t.Turma"); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode($result); Why? How can i remove this?
-
I have a sub table (visitasturmas) whis those field idTurma, idVisita, numberofstudents The main table (visitas) have those fields idVisita, amountVisit, totalPerStudend So this is how it works A teacher can organize study visit: To do this he needs the classes , and how many students of each classes go (since a visit can have several classes, then i have 2 tables for instance, let suppose this configuration idTurma, idVisita, numberofstudents 10 11 20 11 11 15 18 11 17 So i have 3 classes and i have 20+15+17 = 52 students Now i want to remove 3 students from idTurma 18, so now i have 49 students The main table keeps the id, the total amount of the study visit and total for each student Imagine the total amount is 1000, so i must divide by 52 = 19,29 € After removing students the value must change because now is not 52 studens but 49, so it is 20,40 € I can't get this working with mysql SELECT v.Total AS total, SUM(vt.numberofstudents) AS alunos, (total/alunos) AS final FROM visitasturmas vt INNER JOIN visitas v on vt.idVisita = v.idVisita where v.idVisita = 398; I get error [42S22][1054] Unknown column 'alunos' in 'field list'
-
Yes, it seems to be the code since when i use WorkBench i'm able to correct the field to participação I'm going to double check with debug where is the problem Thanks all
-
Thanks for your reply htmlentities where?? before saving to DB i'm sure the data is correct $this->db->query('INSERT INTO tblatividades (atividade, objetivos, haveClasses, participantes, grupoAlvo, orcamento, dataAtividade, hora, local, idAnoEscolar, idProfessor, idProjeto, dataLancado, versao) VALUES (:atividade, :objetivos, :haveClasses, :participantes, :grupoAlvo, :orcamento, :dataAtividade, :hora, :local, :idAnoEscolar, :idProfessor, :idProjeto, NOW(),:versao)'); //Bind values $this->db->bind(':atividade', $data['atividade']); $this->db->bind(':objetivos', $data['objetivos']); $this->db->bind(':haveClasses', $data['haveClasses']); $this->db->bind(':participantes',$data['participantes']); $this->db->bind(':grupoAlvo', $data['grupoAlvo']); $this->db->bind(':orcamento', $data['orcamento']); $this->db->bind(':dataAtividade', $dataAtividade); $this->db->bind(':hora', $data['hora']); $this->db->bind(':local', $data['local']); $this->db->bind(':idAnoEscolar', $idAnoEscolar); $this->db->bind(':idProfessor', $data['idProfessor']); $this->db->bind(':idProjeto',$idProjeto); $this->db->bind(':versao', $versao); $turma = $data['idTurma']; $idProfessores = $data['idProfessores']; $idAtividade =$this->db->execute(); $this->db->bind(':atividade', $data['atividade']); echo this, gives me "Participação"but saved as "Participaçã" The character set is the same for both tables and the collation either, so i don't get why this is happening This is my db connection <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); setlocale( LC_ALL, "pt_PT.UTF-8"); class Database { private $host = ''; private $user = ''; private $pass = ''; private $dbname = ''; private $charset = ""; //Will be the PDO object private $dbh; private $stmt; private $error; public function __construct(){ //Set DSN $dsn = "mysql:host=$this->host;dbname=$this->dbname;charset=utf8mb4"; //Create PDO instance try{ $this->dbh = new PDO($dsn, $this->user, $this->pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES"')); }catch(PDOException $e){ $this->error = $e->getMessage(); echo $this->error; } } //Prepare statement with query public function query($sql){ $this->stmt = $this->dbh->prepare($sql); } //Bind values, to prepared statement using named parameters public function bind($param, $value, $type = null){ if(is_null($type)){ switch(true){ case is_int($value): $type = PDO::PARAM_INT; break; case is_bool($value): $type = PDO::PARAM_BOOL; break; case is_null($value): $type = PDO::PARAM_NULL; break; default: $type = PDO::PARAM_STR; } } //echo $this->stmt->bindValue($param, $value, $type); $this->stmt->bindParam($param, $value, $type); } //Execute the prepared statement public function execute(){ $info = $this->stmt->execute(); $id = $this->lastIdInserted(); if($id != 0){ $info = $id; } else{ if($info){ $info = true; } else{ $info = false; } } return $info; } //Return multiple records public function resultSet(){ $this->execute(); return $this->stmt->fetchAll(PDO::FETCH_ASSOC); } //Return a single record public function single(){ $this->execute(); return $this->stmt->fetch(PDO::FETCH_ASSOC); } //Get row count public function rowCount(){ return $this->stmt->rowCount(); } public function lastIdInserted(){ return $this->dbh->lastInsertId(); } }
-
Hello I'm having a problem regarding saving data into database I have 2 tables, one is keeping the character set defined, the other no So, in one table i put "Participação" and it is saved as "Participaçã" The other table i put "Participação" and it is saved as "Participação". Both have the sames settings So any help what can it be??
-
Hello I'm trying to find the right solution to get only one record in my query but i'm getting 9 records. So when i'm inserting a new record in main main table (visitas) other data is inserted into 3 other tables (MN) like teachers, departments and classes names I'm using this query, and i'm using group concat, it works well whith classes (turmas) and departments(dpt) but with teachers names it gives 9 records 3* classes, 2 departments and 3 teachers The query select n.idvisita, n.destino, t5.nome, GROUP_CONCAT(t4.turma SEPARATOR ', ') as turmas, GROUP_CONCAT(t3.departamento SEPARATOR ', ') as dpt, n.startDate, n.horaSaida, n.endDate, n.horaChegada, n.haveClasses, n.tipoTurma, n.PlanoOcupacaoAlunos, n.PlanoOcupacaoTurmas, n.TipoTransporte, n.CustoTransporte, n.TipoSeguro, n.CustoSeguro, n.TipoEstadia, n.CustoEstadia, n.total, n.TotalAluno, n.Financiamento, GROUP_CONCAT(t5.nome SEPARATOR ', ') as docentes from tblvisitas as n inner join tblvisitas_has_tblturmas as n1 on n.idvisita = n1.idvisita inner join tblturmas t4 on n1.idTurma = t4.idTurma inner join tblvisitas_has_tbldepartamentos tht on n.idvisita = tht.idvisita inner join tbldepartamentos t3 on tht.idDepartamento = t3.idDepartamento inner join tblvisitas_has_tblprofessores as t2 on n.idvisita = t2.idvisita inner join tblprofessores t5 on t2.idProfessor = t5.idProfessor inner join tblanoescolar t on n.idAnoEscolar = t.idAnoEscolar where n.idvisita = 20 and t.estado = 1 GROUP by n.idvisita, n.destino, t5.nome, t4.turma, n.startDate, n.horaSaida, n.endDate, n.horaChegada, n.haveClasses, n.tipoTurma, n.PlanoOcupacaoAlunos, n.PlanoOcupacaoTurmas, n.TipoTransporte, n.CustoTransporte, n.TipoSeguro, n.CustoSeguro, n.TipoEstadia, n.CustoEstadia, n.total, n.TotalAluno, n.Financiamento The data in each MN tables tblvisitas_has_tbldepartamentos table idVisita idDepartamento 20 6 20 1 tblvisitas_has_tblprofessores idVisita idProfessor 20 8 20 9 20 11 tblvisitas_has_tblturmas idVisita idTurma 20 10 20 11 20 23 When i execute the above query i get this The last column is the problem +--------+-------+-----------+------------+-------------------------------------------------------------------------+----------+---------+----------+-----------+-----------+------------------------------------+-------------------+-------------------+----------------------------+---------------+----------+-----------+-----------+------------+--------------+------------+----------------------------------+------------------------+ |idvisita|destino|nome |turmas |dpt |startDate |horaSaida|endDate |horaChegada|haveClasses|tipoTurma |PlanoOcupacaoAlunos|PlanoOcupacaoTurmas|TipoTransporte |CustoTransporte|TipoSeguro|CustoSeguro|TipoEstadia|CustoEstadia|total |TotalAluno |Financiamento |docentes | +--------+-------+-----------+------------+-------------------------------------------------------------------------+----------+---------+----------+-----------+-----------+------------------------------------+-------------------+-------------------+----------------------------+---------------+----------+-----------+-----------+------------+--------------+------------+----------------------------------+------------------------+ |20 |Lisboa |Justino |A-CAL, A-CAL|Departament de Educação Pré-Escolar , Matemática e Ciências Experimentais|2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Justino, Justino | |20 |Lisboa |Justino |A-VP, A-VP |Matemática e Ciências Experimentais, Departament de Educação Pré-Escolar |2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Justino, Justino | |20 |Lisboa |Justino |B-CAL, B-CAL|Matemática e Ciências Experimentais, Departament de Educação Pré-Escolar |2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Justino, Justino | |20 |Lisboa |Teste |A-CAL, A-CAL|Matemática e Ciências Experimentais, Departament de Educação Pré-Escolar |2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste, Teste | |20 |Lisboa |Teste |A-VP, A-VP |Departament de Educação Pré-Escolar , Matemática e Ciências Experimentais|2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste, Teste | |20 |Lisboa |Teste |B-CAL, B-CAL|Matemática e Ciências Experimentais, Departament de Educação Pré-Escolar |2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste, Teste | |20 |Lisboa |Teste final|A-CAL, A-CAL|Matemática e Ciências Experimentais, Departament de Educação Pré-Escolar |2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste final, Teste final| |20 |Lisboa |Teste final|A-VP, A-VP |Departament de Educação Pré-Escolar , Matemática e Ciências Experimentais|2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste final, Teste final| |20 |Lisboa |Teste final|B-CAL, B-CAL|Departament de Educação Pré-Escolar , Matemática e Ciências Experimentais|2023-05-09|12:00:00 |2023-05-12|12:00:00 |Sim |Científico/Humanístico|Todas |Todas |Avião;Autocarro;Barco|2000 |Sim |500 |Sim |500 |3500.00 €|83.00 €|Escola;POCH;Câmara Municipal|Teste final, Teste final| +--------+-------+-----------+------------+-------------------------------------------------------------------------+----------+---------+----------+-----------+-----------+------------------------------------+-------------------+-------------------+----------------------------+---------------+----------+-----------+-----------+------------+--------------+------------+----------------------------------+------------------------+
-
I'm trying to run a query but my outcome is not what i need. So the problem is: A user can be diretor and if this is the case he can see all activities from his department, and he can be user of another department too, in this case not director but only user. I have 8 departments each with one director, so the following query should give me the activities of the department and the activities of this particular user in other department: SELECT t1.idAtividade, t1.idProfessor, t2.Escola, t1.Atividade, t1.Periodo, t1.Mes, t1.haveClasses, t1.DataPrevista, t1.Destinatarios, t1.Orcamento, t1.PdfAtividade, t1.Avaliacao, t1.PdfAvaliacao, t1.idProfessor, p.Nome, d.Departamento, p2.Projeto, t1.idProjeto FROM atividades AS t1 INNER JOIN professores p on t1.idProfessor = p.idProfessor RIGHT JOIN atividadesgrupos ag on t1.idAtividade = ag.idAtividade RIGHT JOIN departamentosatividades da on t1.idAtividade = da.idAtividade RIGHT JOIN departamentos d on da.idDepartamento = d.idDepartamento INNER JOIN escolas AS t2 ON (t2.idEscola = t1.idEscola) INNER JOIN anosescolares AS ae ON (t1.idAnoEscolar = ae.idAnoEscolar) INNER JOIN projetos p2 on t1.idProjeto = p2.idProjeto WHERE ae.Estado = 1 AND da.idDepartamento = 8 ORDER BY (t1.idProfessor = 60) DESC, t1.idProfessor; This query is not working because the department have 22 activities but this user (idProfessor) has 5 in this department and 14 more in another department (defined by idGrupo) I think i will need a subquery right?
-
Hi Kicken Thank's for helping me. You are right about your explanation. I have followed your explaination and tried your code but there is an error, the var_export of the code provided gives me this array array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-22', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-23', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-29', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-30', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-06', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-07', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-13', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-14', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-20', 'tempos' => '1', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-20', 'tempos' => '3', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-27', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-28', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-03', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-04', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-10', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-11', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-17', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-18', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-24', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-25', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-02', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-09', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-15', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-16', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2021-01-05', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2021-01-06', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-12', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-13', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-19', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-20', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-26', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-27', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-02', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-03', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-09', 'tempos' => '1', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( ) When it reachs this line in your code $date = $level2['dataAula']; I have this error <b>Warning</b>: Illegal string offset 'dataAula' But when i see the array, it looks right to me.....what do i missing? Thanks
-
Hello I have an array where i want the join values (not sum) where the date are the same This my array(var_export) array ( 0 => array ( 0 => array ( 0 => array ( 'dataAula' => '2020-09-21', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 4, ), ), 1 => array ( 1 => array ( 'dataAula' => '2020-09-22', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 8, ), ), 2 => array ( 2 => array ( 'dataAula' => '2020-09-28', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 12, ), ), 3 => array ( 3 => array ( 'dataAula' => '2020-09-29', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 16, ), ), 4 => array ( 4 => array ( 'dataAula' => '2020-10-06', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 20, ), ), 5 => array ( 5 => array ( 'dataAula' => '2020-10-12', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 24, ), ), 6 => array ( 6 => array ( 'dataAula' => '2020-10-13', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 28, ), ), 7 => array ( 7 => array ( 'dataAula' => '2020-10-19', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 32, ), ), 8 => array ( 8 => array ( 'dataAula' => '2020-10-20', 'tempos' => 1, 'tempos2' => 'Terça', 'total' => 33, ), ), ), 1 => array ( 0 => array ( 0 => array ( 'dataAula' => '2020-10-20', 'tempos' => 3, 'tempos2' => 'Segunda', 'total' => 3, ), ), 1 => array ( 1 => array ( 'dataAula' => '2020-10-27', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 7, ), ), 2 => array ( 2 => array ( 'dataAula' => '2020-11-02', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 11, ), ), 3 => array ( 3 => array ( 'dataAula' => '2020-11-03', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 15, ), ), 4 => array ( 4 => array ( 'dataAula' => '2020-11-09', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 19, ), ), 5 => array ( 5 => array ( 'dataAula' => '2020-11-10', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 23, ), ), 6 => array ( 6 => array ( 'dataAula' => '2020-11-16', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 27, ), ), 7 => array ( 7 => array ( 'dataAula' => '2020-11-17', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 31, ), ), 8 => array ( 8 => array ( 'dataAula' => '2020-11-23', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 35, ), ), 9 => array ( 9 => array ( 'dataAula' => '2020-11-24', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 39, ), ), 10 => array ( 10 => array ( 'dataAula' => '2020-11-30', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 43, ), ), 11 => array ( 11 => array ( 'dataAula' => '2020-12-07', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 47, ), ), 12 => array ( 12 => array ( 'dataAula' => '2020-12-14', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 51, ), ), 13 => array ( 13 => array ( 'dataAula' => '2020-12-15', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 55, ), ), 14 => array ( 14 => array ( 'dataAula' => '2021-01-04', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 59, ), ), 15 => array ( 15 => array ( 'dataAula' => '2021-01-05', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 63, ), ), 16 => array ( 16 => array ( 'dataAula' => '2021-01-11', 'tempos' => 4, 'tempos2' => 'Segunda', 'total' => 67, ), ), ), 2 => array ( 0 => array ( 0 => array ( 'dataAula' => '2021-01-12', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 4, ), ), 1 => array ( 1 => array ( 'dataAula' => '2021-01-18', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 8, ), ), 2 => array ( 2 => array ( 'dataAula' => '2021-01-19', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 12, ), ), 3 => array ( 3 => array ( 'dataAula' => '2021-01-25', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 16, ), ), 4 => array ( 4 => array ( 'dataAula' => '2021-01-26', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 20, ), ), 5 => array ( 5 => array ( 'dataAula' => '2021-02-01', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 24, ), ), 6 => array ( 6 => array ( 'dataAula' => '2021-02-02', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 28, ), ), 7 => array ( 7 => array ( 'dataAula' => '2021-02-08', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 32, ), ), 8 => array ( 8 => array ( 'dataAula' => '2021-02-09', 'tempos' => 1, 'tempos2' => 'Terça', 'total' => 33, ), ), ), )[] So, for example i have repeated the date 2020-10-20, one with "tempos =1" and another with "tempos=3" I'm looking to have only one date with concatened tempos field Example array ( 'dataAula' => '2020-10-20', 'tempos' => 1+3, 'tempos2' => 'Terça', 'total' => 33, ), So what i have now is this code but not getting what i need foreach ($finalCronograma as $sub) { $row = current($sub); if (isset($result[$row[0]['dataAula']])) { $result[$row[0]['dataAula']]['tempos'] .= '+' . $row[0]['tempos']; } else { $result[$row[0]['dataAula']] = $sub; } } any help?
-
No, no limit But usually a class don't have more than 7/8 hours week in specific subject(for instance, multimedia have in one subject with 8 hours per week, 3 hours with all student class + 5 hours each group(class divided in 2) Sending my form to get full picture Regards