Jump to content

gmc1103

Members
  • Posts

    251
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Hello yes, this is what i'm looging for Thanks for helping me
  2. Hello I'm trying to remove null ou 0 values from my array but i can't get it to work properly This is my array Array ( [0] => Array ( [0] => 2020-09-21 [1] => 3 ) [1] => Array ( [0] => 2020-09-23 [1] => 2 ) [2] => Array ( [0] => 2020-09-28 [1] => 3 ) [3] => Array ( [0] => 2020-09-30 [1] => 2 ) [4] => Array ( [0] => 2020-10-07 [1] => 2 ) [5] => Array ( [0] => 2020-10-12 [1] => 3 ) [6] => Array ( [0] => 2020-10-14 [1] => 2 ) [7] => Array ( [0] => 2020-10-19 [1] => 3 ) [8] => Array ( [0] => 2020-10-21 [1] => 2 ) [9] => Array ( [0] => 2020-10-26 [1] => 3 ) [10] => Array ( [0] => 2020-10-28 [1] => 2 ) [11] => Array ( [0] => 2020-11-02 [1] => 3 ) [12] => Array ( [0] => 2020-11-04 [1] => 2 ) [13] => Array ( [0] => 2020-11-09 [1] => 3 ) [14] => Array ( [0] => 2020-11-11 [1] => 2 ) [15] => Array ( [0] => 2020-11-16 [1] => 3 ) [16] => Array ( [0] => 2020-11-18 [1] => 2 ) [17] => Array ( [0] => 2020-11-23 [1] => 3 ) [18] => Array ( [0] => 2020-11-25 [1] => 2 ) [19] => Array ( [0] => 2020-11-30 [1] => 3 ) [20] => Array ( [0] => 2020-12-02 [1] => 2 ) [21] => Array ( [0] => 2020-12-07 [1] => 3 ) [22] => Array ( [0] => 2020-12-09 [1] => 2 ) [23] => Array ( [0] => 2020-12-14 [1] => 3 ) [24] => Array ( [0] => 2020-12-16 [1] => 2 ) [25] => Array ( [0] => 2021-01-04 [1] => 3 ) [26] => Array ( [0] => 2021-01-06 [1] => 2 ) [27] => Array ( [0] => 2021-01-11 [1] => 3 ) [28] => Array ( [0] => 2021-01-13 [1] => 2 ) [29] => Array ( [0] => 2021-01-18 [1] => 3 ) [30] => Array ( [0] => 2021-01-20 [1] => 2 ) [31] => Array ( [0] => 2021-01-25 [1] => 3 ) [32] => Array ( [0] => 2021-01-27 [1] => 2 ) [33] => Array ( [0] => 2021-02-01 [1] => 3 ) [34] => Array ( [0] => 2021-02-03 [1] => 2 ) [35] => Array ( [0] => 2021-02-08 [1] => 3 ) [36] => Array ( [0] => 2021-02-10 [1] => 2 ) [37] => Array ( [0] => 2021-02-17 [1] => 2 ) [38] => Array ( [0] => 2021-02-22 [1] => 3 ) [39] => Array ( [0] => 2021-02-24 [1] => 2 ) [40] => Array ( [0] => 2021-03-01 [1] => 3 ) [41] => Array ( [0] => 2021-03-03 [1] => 2 ) [42] => Array ( [0] => 2021-03-08 [1] => 3 ) [43] => Array ( [0] => 2021-03-10 [1] => 2 ) [44] => Array ( [0] => 2021-03-15 [1] => 3 ) [45] => Array ( [0] => 2021-03-17 [1] => 2 ) [46] => Array ( [0] => 2021-03-22 [1] => 3 ) [47] => Array ( [0] => 2021-03-24 [1] => 2 ) [48] => Array ( [0] => 2021-04-05 [1] => 3 ) [49] => Array ( [0] => 2021-04-07 [1] => 2 ) [50] => Array ( [0] => 2021-04-12 [1] => 3 ) [51] => Array ( [0] => 2021-04-14 [1] => 2 ) [52] => Array ( [0] => 2021-04-19 [1] => 3 ) [53] => Array ( [0] => 2021-04-21 [1] => 2 ) [54] => Array ( [0] => 2021-04-26 [1] => 3 ) [55] => Array ( [0] => 2021-04-28 [1] => 2 ) [56] => Array ( [0] => 2021-05-03 [1] => 3 ) [57] => Array ( [0] => 2021-05-05 [1] => 2 ) [58] => Array ( [0] => 2021-05-10 [1] => 3 ) [59] => Array ( [0] => 2021-05-12 [1] => 0 ) [60] => Array ( [0] => 2021-05-17 [1] => 3 ) [61] => Array ( [0] => 2021-05-19 [1] => 0 ) [62] => Array ( [0] => 2021-05-24 [1] => 3 ) [63] => Array ( [0] => 2021-05-26 [1] => 0 ) [64] => Array ( [0] => 2021-05-31 [1] => 3 ) [65] => Array ( [0] => 2021-06-02 [1] => 0 ) [66] => Array ( [0] => 2021-06-07 [1] => 3 ) [67] => Array ( [0] => 2021-06-09 [1] => 0 ) [68] => Array ( [0] => 2021-06-14 [1] => 1 ) [69] => Array ( [0] => 2021-06-16 [1] => 0 ) [70] => Array ( [0] => 2021-06-21 [1] => 0 ) [71] => Array ( [0] => 2021-06-23 [1] => 0 ) [72] => Array ( [0] => 2021-06-28 [1] => 0 ) [73] => Array ( [0] => 2021-06-30 [1] => 0 ) ) And i'm using this code to remove but no success print_r(array_values(array_filter($cronograma))); Any help please Thanks
  3. Hello I'm having prblem regarding this query, it gives me the following error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':idCursos' at line 12 The query is the following select c.idPlan, cD.disciplina, cM.moduloUfcd, p.Nome, t.Turma, a.Ano, c2.curso, c.validPlan, c.planificacao, c.dataLimite, c.idProfessor, c.pdf,c.inicio,c.fim,c.objetivos,c.conteudos,c.competencias, c.estrategias, c.recursos, c.avaliacao,c.criado from cpDiscProfessores c inner join cpDisciplinas cD on c.idcpDisciplinas = cD.idCpDisciplinas inner join cpModulos cM on c.idCpModulos = cM.idCpModulos inner join professores p on c.idProfessor = p.idProfessor left join turmas t on c.idTurma = t.idTurma inner join anosescolares a on c.idAnoEscolar = a.idAnoEscolar left join cursos c2 on c.idCursos = c2.idCursos where a.Estado = 1 AND c2.idCursos=:idCursos"); $stmt->bindparam(":idCursos", $idCursos, PDO::PARAM_INT Ok, this query accept one pamater, and i have checked it is not empty array(4) { ["total"]=> string(1) "1" [0]=> string(1) "1" ["idCursos"]=> string(1) "1" [1]=> string(1) "1" } IdCursos: 1 isDC: 1 SOLVED: copy/paste and didn't see i was using "query" instead of "prepare"
  4. Hi Barand...you are the boss. Great solution, it works like a charm. Thank you
  5. Hi Thanks for reading and replying But it stops, you can see he has stopped when $sum > $hours what i expect is to get the same value in variable $hours, and in my array. For example i choose monday and i can work 6 hours, Task is 20 hours, so i need 6+6+6+2, but when the user define 6 hours for each monday i will have 6+6+6+6, total is 24. I was thinking in create a statement inside if($isSegunda != null && $sum<$horas){ if ((isSegunda($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null){ $cronograma[$this_month][] = $temposSegunda; } $sum += $temposSegunda; } So before adding the $temposSegunda into the array, i check the total sum and the task hours, and if i get more hours, i remove the number in excess, in this case i have task hours = 20 and the total is 24, the difference is 4, so how can alter this to write the correct value into the array? Any help? Thanks
  6. Hello I'm trying to get this working but i'm stuck I'm making a program who must define dates and time (hours) to a task So in the beginning i define: how many hours the task will have the week days the max hour per day The following code is working well except if the total is 20, and i have the sum of 18, the script allows to add more than 2 hours before stop the execution Example running the script hours defined: 20 Data: 2020-09-01 -Hours:4 Data: 2020-09-07 -Hours:2 Data: 2020-09-08 -Hours:4 Data: 2020-09-14 -Hours:2 Data: 2020-09-15 -Hours:4 Data: 2020-09-21 -Hours:2 Data: 2020-09-22 -Hours:4 Total: 22 This is my code ( the problem should be inside foreach range code) define('INTERNAL_FORMAT', 'Y-m-d'); $startDate = "2020-09-01"; $start_date1 = strtotime("2020-09-01"); $endDate = strtotime("2021-06-30"); $horas = "20"; $sum = 0; $datediff = round(($endDate - $start_date1) / (60 * 60 * 24)) ; $res = array('01-01','02-25','04-10','04-12','04-25','05-01','06-10', '06-11', '08-15', '10-05', '11-01', '12-01', '12-08', '12-25'); $period = new DatePeriod( new DateTime('2021-03-27'), new DateInterval('P1D'), new DateTime('2021-04-16') ); $arr = array(); foreach ($period as $key => $value) { $arr[] = $value->format('m-d'); } $excluded_dates = array_merge($res, $arr); function isSegunda($date) { return date('w', strtotime($date)) === '1'; } function isTerca($date) { return date('w', strtotime($date)) === '2'; } function isQuarta($date) { return date('w', strtotime($date)) === '3'; } function isQuinta($date) { return date('w', strtotime($date)) === '4'; } function isSexta($date) { return date('w', strtotime($date)) === '5'; } // handle the excluded dates function isExcludedDate($internal_date) { global $excluded_dates; $str2 = substr($internal_date, 5); foreach($excluded_dates as $row){ return in_array($str2, $excluded_dates); } } // something to store months and days $cronograma = array(); $isSegunda = "1"; $isTerca = "2"; $isQuarta = ""; $isQuinta = ""; $isSexta = ""; $temposSegunda = "2"; $temposTerca = "4"; $temposQuarta = "4"; $temposQuinta = "4"; $temposSexta = "4"; foreach(range(0,$datediff) as $day) { $internal_date = date(INTERNAL_FORMAT, strtotime("{$startDate} + {$day} days")); $this_day = date(INTERNAL_FORMAT, strtotime($internal_date)); $this_month = date(INTERNAL_FORMAT, strtotime($internal_date)); if($isSegunda != null && $sum<$horas){ if ((isSegunda($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null){ $cronograma[$this_month][] = $temposSegunda; } $sum += $temposSegunda; } } if($isTerca != null && $sum<$horas){ if ((isTerca($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposTerca != null){ $cronograma[$this_month][] = $temposTerca; } $sum += $temposTerca; } } if($isQuarta != null){ if ((isQuarta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuarta != null){ $cronograma[$this_month][] = $temposQuarta; } } } if($isQuinta != null){ if ((isQuinta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuinta != null){ $cronograma[$this_month][] = $temposQuinta; } } } if($isSexta !=null){ if ((isSexta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSexta != null){ $cronograma[$this_month][] = $temposSexta; } } } } $soma = 0; echo "hours defined: ".$horas; print "<br>"; foreach($cronograma as $month => $days) { $dias = $days[0]; $tempos = $days[1]; echo "Data: ".$dias." -Hours:".$tempos; print "<br>"; $soma+= $days[1]; } echo "Total: ".$soma; Any help? Thanks
  7. Hello In my query i have x activities, then i have the count of how many still to be executed, i need to get the percentage of the total executed I mean i have 200 activities, 20 have been executed, so i want to have 10% done My query is this one but missing the percentage field SELECT COUNT(*) AS total, IFNULL(SUM(CASE WHEN (t1.dataPrevista >= CURDATE() OR ae.Fim <= CURDATE()) THEN 1 ELSE 0 END),0) AS exec FROM atividades AS t1 INNER JOIN anosescolares AS ae ON (t1.`idAnoEscolar` = ae.idAnoEscolar) WHERE ae.Estado = 1; any help?
  8. Hi Barand Thanks for helping me Sorry, i forgot to put the query "SELECT t1.idAtividade, t2.Escola, t1.Atividade, t1.Periodo, t1.Mes, t1.haveClasses, t1.DataPrevista, t1.Destinatarios, t1.Orcamento, t1.Organizador, t1.Obs, t1.PdfAtividade, t1.Avaliacao, t1.idProfessor, t1.PdfAvaliacao, p.Nome, g.Grupo, d.Departamento, t1.Validado FROM atividades AS t1 INNER JOIN atividadesprofessores ap on t1.idAtividade = ap.idAtividade INNER JOIN professores p on ap.idProfessor = p.idProfessor INNER JOIN atividadesgrupos ag on t1.idAtividade = ag.idAtividade INNER JOIN grupos g on ag.idGrupo = g.idGrupo INNER JOIN departamentosatividades da on t1.idAtividade = da.idAtividade INNER 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) WHERE t1.idProjeto IS NULL AND ae.Estado = 1 ORDER BY t1.DataPrevista ASC
  9. Hi I have an array from an sql query and i would like to eliminates all the duplicates, i have google search for an answer without success, any help would be aprecciated $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $final = array(); $json = array(); if ($idCoord > 0 || $isDirecao > 0) { foreach ($result as $row) { $idAtividade = $row['idAtividade']; if (!isset($final[$idAtividade])) { $final[$idAtividade]['Escola'] = $row['Escola']; $final[$idAtividade]['Atividade'] = $row['Atividade']; $final[$idAtividade]['Periodo'] = $row['Periodo']; $final[$idAtividade]['Mes'] = $row['Mes']; $final[$idAtividade]['haveClasses'] = $row['haveClasses']; $final[$idAtividade]['DataPrevista'] = $row['DataPrevista']; $final[$idAtividade]['Destinatarios'] = $row['Destinatarios']; $final[$idAtividade]['Orcamento'] = $row['Orcamento']; $final[$idAtividade]['Organizador'] = $row['Organizador']; $final[$idAtividade]['Obs'] = $row['Obs']; $final[$idAtividade]['PdfAtividade'] = $row['PdfAtividade']; $final[$idAtividade]['Avaliacao'] = $row['Avaliacao']; $final[$idAtividade]['idProfessor'] = $row['idProfessor']; $final[$idAtividade]['PdfAvaliacao'] = $row['PdfAvaliacao']; $final[$idAtividade]['Validado'] = $row['Validado']; $final[$idAtividade]['Nome'] = array(); $final[$idAtividade]['Grupo'] = array(); $final[$idAtividade]['Departamento'] = array(); } $final[$idAtividade]['Nome'][] = $row['Nome']; $final[$idAtividade]['Grupo'][] = $row['Grupo']; $final[$idAtividade]['Departamento'][] = $row['Departamento']; } foreach ($final as $idVisita => $reservation) { $json[] = $reservation; } } echo json_encode($json); } And this is an example i'm receiving So you can see that Grupo has 4 times the value "500" and Departamento has 4 times that string... How can avoid this and have only one value of each? Thanks
  10. Hi Thank you. For the first item yes it does, but i have 5 items, then i want the percentage of each one.
  11. Hi I need some help regarding a chart i'm trying to make regarding my table data This is the structure CREATE TABLE `rel_atividades_avaliacao` ( `id_avaliacao` int(11) NOT NULL AUTO_INCREMENT, `id_atividades` int(11) NOT NULL, `avaliado` varchar(3) COLLATE utf8_bin NOT NULL DEFAULT '-1', `data_prevista` varchar(50) COLLATE utf8_bin NOT NULL, `motivo` varchar(300) COLLATE utf8_bin DEFAULT '-', `adequacaos` int(11) NOT NULL, `participacaos` int(11) NOT NULL, `consecucaos` int(11) NOT NULL, `disps` int(11) NOT NULL, `mats` int(11) NOT NULL, `balanco` varchar(300) COLLATE utf8_bin NOT NULL, `ficheiro` varchar(300) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id_avaliacao`), KEY `id_atividades` (`id_atividades`), CONSTRAINT `rel_atividades_avaliacao_ibfk_1` FOREIGN KEY (`id_atividades`) REFERENCES `atividades` (`id_atividades`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=533 DEFAULT CHARSET=utf8 COLLATE=utf8_bin The chart should be regarding those 5 elements `adequacaos` int(11) NOT NULL, `participacaos` int(11) NOT NULL, `consecucaos` int(11) NOT NULL, `disps` int(11) NOT NULL, `mats` int(11) NOT NULL, Those 5 elements accept numbers between 1 to 5, 1(poor) and 5 (Excellent) So my chart must be how many times 1, 2,3,4,5 has been chosed in each table atributes Any help? Thanks
  12. Thanks But i keep the rel_visitas_utilizador table? with id_visita and id_user?
  13. I understand the application, When the user schedule the study visit, the data is inserted into the visitas table, then the id generated in the table visitas is inserted into the rel_visitas_utilizador. My question was if that implementation (all tables are correct or can they can be improved). The table rel_visitas_utilizador is where is keeped some extra informations about that visit (like pdf file, validate or not, realizado(made or not), etc). About the 1-N, I doubt since rel_visitas_utilizador should only keep one id, can't be repeated
  14. Hi Requinix Right now is what i see in the database. For me it's sound a little confusing. I understand the schema, but regarding the point you mention it seems it's 1_N from visitas to rel_visitas_utilizador..
  15. Hi I'm still developing my database and now i have another task So in my school i have teachers, table Utilizador id_utilizador(teacher) The table visitas have the following data. id; classroom_id; place_visit; date_leaving; hour_leaving; date_arriving; hour_arriving; subjects(teachers subjects); teachers; objectives; transportation; price; students(how many); itinerary; observations; id_year (school year; registered (date) Classroom table turmas id_turma(classroom_id); classroom_name active(yes/no) My related table rel_visitas_utilizador id_visita(foreign key); id_utilizador(foreign key) done(yes/no) valid(yes/no) file(pdf generated and saved in webserver path) So right now this is how this work, teh process A teacher must can schedule a study visit, when he fill the form, all the data from form are sent the the manager and he must define if this visit is valid or no (rel_visitas_utilizador). So with the following explanation and the image provided can someone give me some suggestions to improve this database? Any questions, just ask
  16. Ok Let me show what i have Using this query SELECT dpt FROM visitas_estudo WHERE id_visita = 28 I have dpt --------- 4,6,2,3 this is 4 (id's) regarding the departamentos table So i need to get those values (ids) and using a foreach loop get all the subjects of that. That's why i have 2 query, first one to get all the id's and then with those id's making another query to get the subject, attach all the an array and then send it to pdf file the return should be something like Artes, Ciências Sociais e Humanas,Linguas Estrangeiras,Matemática e Informática,Português
  17. Hi Jacques No..let me explain What is stored into the database is some id's, that's the way they want. What i need is get all the id's and then return the values of those id's for instance id 1 ......Math 2.......Portuguese 3.......English and so on. So, when i want to get all the subjects, i need to get them from the id stored in the database. About the code, first i want to collect the id's stored in the dpt field; second, from the array, i execute the loop to get the values of each id and store them in an array; then i have all subjects in a string Maybe isn't the best approach but i'm still learning Regards
  18. Hi Barand How are you? Thanks for the answer but i still hava a problem....it only gives me one, when it shoud be 4 The code <?php error_reporting(E_ALL); ini_set('display_errors', 1); header('Content-type: application/json'); require_once("./dbconfig.php"); $esmaior = new ESMAIOR($DB_con); $id_visita = 28; try { $stmt = $DB_con->prepare("SELECT dpt FROM visitas_estudo where id_visita = :id_visita"); $stmt->bindParam(':id_visita', $id_visita, PDO::PARAM_INT); $stmt->execute(); $dpts = $stmt->fetchAll(PDO::FETCH_COLUMN); var_dump($dpts); if($stmt->rowCount() > 0) { $stmt = $DB_con->prepare("SELECT departamento FROM departamentos where id_departamento = :id_departamento"); foreach ($dpts as $id) { $stmt->bindParam(':id_departamento', $id, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_COLUMN); $nome_dpt = array(); foreach ($result as $departamentos) { $nome_dpt[] = $departamentos; } } } var_dump($nome_dpt); $nomes = implode(';', $nome_dpt); echo $nomes; } catch (PDOException $e) { echo $e->getMessage(); } and the var_dump It looks the loop it only executed one time only array(1) { [0]=> string(7) "4,6,2,3" } array(1) { [0]=> string(6) "Artes " } Artes right?
  19. Hi I'm having a problem regarding the following code and i don't get whats is wrong with that <?php error_reporting(E_ALL); ini_set('display_errors', 1); header('Content-type: application/json'); require_once("./dbconfig.php"); $esmaior = new ESMAIOR($DB_con); $id_visita = 28; try { $stmt = $DB_con->prepare("SELECT dpt FROM visitas_estudo where id_visita = :id_visita"); $stmt->bindParam(':id_visita', $id_visita, PDO::PARAM_INT); $stmt->execute(); $dpts = $stmt->fetchAll(PDO::FETCH_COLUMN); if($stmt->rowCount() > 0) { $stmt = $DB_con->prepare("SELECT departamento FROM departamentos where id_departamento = :id_departamento"); $departamento = implode(',', $dpts); $nome_dpt = array(); echo $departamento; foreach ($departamento as $id) { $stmt->bindParam(':id_departamento', $id, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_COLUMN); foreach ($result as $departamentos) { $nome_dpt[] = $departamentos; } } $nomes = implode(';', $nome_dpt); echo $nomes; } } catch (PDOException $e) { echo $e->getMessage(); } The problem is the foreach loop 4,6,2,3<br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/esmaior/public_html/miga/db/testes.php</b> on line <b>18</b><br /> I have the echo (gives me 4,6,2,3) but when it enter the loop it say invalid argument... Not sure what is wrong
  20. Hi mac I will try to implement the way you say, any problem i will be back Thanks to you and Barand
  21. Hi Mac and Barand Mac, you are problably right, the problem is i'm getting an array, and then i want to use explode to separate the items and then execute the loop. The way you say it's better but i never use that approach detect if the insert query returned a unique index error. How?? Barand, i have read the website you gave me, you are talking about the The Booking Process, right? I have managed to make it working but with a lot of if statements, and this is not the best way. best regards
  22. Ok Let me explain better with my strange english The diagram i was working it is to make a new database but until is not ready i have this problem An user want to make a reservation of a classroom for instance all morning From 8:15 until 13:20 So until 13:20 i have 5 time period If i choose only one time period...the function i put in my first post works, but if i put 2,3,4 don't. So the fisrt fucntion public function reqSalas($data, $atividade, $id_utilizador, $id_bloco, $id_sala) call in the first line $sala = $this->getDisponibilidadeSala($data, $id_bloco, $id_sala); public function getDisponibilidadeSala($data, $id_bloco, $id_sala){ try { $stmt = $this->db->prepare("SELECT COUNT(*) AS total FROM rel_requisicoes_detalhes AS t1 INNER JOIN requisicoes AS t2 ON (t1.id_requisicoes = t2.id_requisicoes) WHERE t1.id_bloco = :id_bloco AND t1.id_sala = :id_sala AND t2.datas = :datas;"); $stmt->bindparam(":datas", $data, PDO::PARAM_STR); $stmt->bindparam(":id_bloco", $id_bloco, PDO::PARAM_INT); $stmt->bindparam(":id_sala", $id_sala, PDO::PARAM_INT); if (!$stmt->execute()) { print_r($stmt->errorInfo()); return false; } else { $result = $stmt->fetchColumn(); return $result; } } catch (Exception $ex) { echo $ex->getMessage(); } } This function check if the $id_bloco is already in a reservation as long the $data and $id_sala(classroom) With one time period, it works well, with more...don't Check the picture and follow what i gonna write So look the number one in red, this user made a reservation in 12/12/2016 at 10:00 Then number 2,3,4 made a reservation from 9 AM until 10:45 (this makes 3 time periods), so since the fisrt time period was clear, the function add to the database different users in same classroom and same time period. 1 and 3 Better explained?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.