Jump to content

gmc1103

Members
  • Posts

    258
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Hi I would like some help with this query, the purpose is when someone make an activity , after the date he must define if that activity has been done or not, and i want to put an alert until those fields are registered into the database The query is this one SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE `idutilizador` =1355 AND `data` >= CURDATE( ) AND `realizado` IS NULL OR LENGTH( `realizado` ) =0 But i have always 1 because of the last "and", how can i fix this??
  2. Thanks Can you give me an example , i never used this before Regards
  3. Hi I have an insert code into my database and if the result of the insert is ok an emal is sended to to admin but when i use this function (email) the user receives the json response after several seconds and not right away like he does when i don't use this function, anyone knows why? This is my code $sql = "SELECT COUNT( * ) as total_count FROM `new_visitas` WHERE `id_user`= ? AND `data_partida` = ? AND `hora_partida` = ?"; $stmt = $mysqli->prepare($sql); if ($stmt === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $mysqli->error, E_USER_ERROR); } $stmt->bind_param('iss', $iduser, $data_partida, $hora_partida); $stmt->execute(); $stmt->bind_result($existe); $stmt->fetch(); $stmt->close(); if ($existe != 0) { $response = "Erro...Existe sobreposição nesse dia/hora para este utilizador."; echo json_encode(array('status' => 'error', 'message' => 'Erro...Existe sobreposição nesse dia/hora para este utilizador.')); } else { $sql = "INSERT INTO `new_visitas` (`id_user`, `local`, `data_partida`, `hora_partida`, `data_chegada`, `hora_chegada`, `turmas`, `disc`, `docentes`, `obj`, `tp`, `custo`, `total`, `itinerario`, `obs`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $mysqli->prepare($sql); if ($stmt === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $mysqli->error, E_USER_ERROR); } $stmt->bind_param('issssssssssssss', $iduser, $newLocal, $data_partida, $hora_partida, $data_chegada, $hora_chegada, $newTurmas, $newDis, $newDocentes, $newObj, $newTp, $newCusto, $alunos, $newIti, $newObs); if (!$stmt->execute()) { echo json_encode(array('status' => 'error', 'message' => 'Opppss...A visita não foi registada')); } else { echo json_encode(array('status' => 'success', 'message' => 'A sua visita foi registada...Obrigado')); enviarEmail($newLocal,$data_partida, $hora_partida, $data_chegada, $hora_chegada, $newTurmas, $newDis, $newDocentes,$custo, $alunos); } $stmt->close(); } function enviarEmail($newLocal,$data_partida, $hora_partida, $data_chegada, $hora_chegada, $newTurmas, $newDis, $tp,$custo, $alunos){ $adress = "[email protected]"; $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPDebug = 3; $mail->Mailer = "smtp"; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->SMTPKeepAlive = true; $mail->SMTPAuth = true; $mail->Username = "[email protected]"; $mail->Password = "0942sv"; $mail->From = '[email protected]'; $mail->FromName = "EBSPMA - PAAD"; $mail->addReplyTo('[email protected]', 'PAAD - Atividades'); $mail->AddAddress($adress, "PAAD"); $mail->IsHTML(true); $mail->Subject = 'Registo de nova visita de estudo'; $mail->CharSet = 'UTF-8'; $mail->Body = " <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> </head> <body> <h1>Visita de Estudo</h1> <p>Seguem os dados desta visita de estudo</p> <table> <tbody> <tr> <td><strong>Visita de Estudo</strong></td> <td>$newLocal</td> </tr> <tr> <td><strong>Data Partida</strong></td> <td>$data_partida</td> </tr> <tr> <td><strong>Hora Partida</strong></td> <td>$hora_partida</td> </tr> <tr> <td><strong>Data Chegada</strong></td> <td>$data_chegada</td> </tr> <tr> <td><strong>Hora Chegada</strong></td> <td>$hora_chegada</td> </tr> <tr> <td><strong>Turmas</strong></td> <td>$newTurmas</td> </tr> <tr> <td><strong>Disciplinas</strong></td> <td>$newDis</td> </tr> <tr> <td><strong>Transporte</strong></td> <td>$tp</td> </tr> <tr> <td><strong>Custo</strong></td> <td>$custo</td> </tr> <tr> <td><strong>Total Alunos</strong></td> <td>$alunos</td> </tr> </tbody> </table> <p> </p> <p>Aceda à sua área para validar esta visita de estudo e gerar os PDFs</p> <p> </p> <p>Equipa PAAD.</p> <p> </p> <p>Obrigado</p> </body> </html>"; if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; exit(); } else { exit(); } } Any recomendations to avoid this delay? Thanks
  4. gmc1103

    query help

    Hi Barand Thanks for your information, i fixed the issue using group by day, class, time, then order by day and time. Thanks
  5. gmc1103

    query help

    Hello I'm having a problem regarding a query because i don't have all the records and i don't know why This is the query SELECT `ebspma_paad_ebspma`.`semana_dias`.`dia`,`ebspma_paad_ebspma`.`req_material_sala`.`sala`, `ebspma_paad_ebspma`.`req_material_tempo`.`inicio`, `ebspma_paad_ebspma`.`sala_ocupacao`.`id_ocup`, `ebspma_paad_ebspma`.`turmas`.`turma` FROM `ebspma_paad_ebspma`.`sala_ocupacao` INNER JOIN `ebspma_paad_ebspma`.`semana_dias` ON (`sala_ocupacao`.`id_dia` = `semana_dias`.`id_dia`) INNER JOIN `ebspma_paad_ebspma`.`req_material_sala` ON (`sala_ocupacao`.`id_sala` = `req_material_sala`.`idsala`) LEFT JOIN `ebspma_paad_ebspma`.`req_material_tempo` ON (`sala_ocupacao`.`id_tempo` = `req_material_tempo`.`idtempo`) LEFT JOIN `ebspma_paad_ebspma`.`turmas` ON (`sala_ocupacao`.`id_turma` = `turmas`.`id_turma`) where`ebspma_paad_ebspma`.`sala_ocupacao`.`id_turma` = '$turma' GROUP BY `ebspma_paad_ebspma`.`sala_ocupacao`.`id_dia` , `ebspma_paad_ebspma`.`req_material_tempo`.`inicio` ASC And i have this result (school_result.jpg) and it should be (school_result_correct.jpg) because in my school timetable i have two classroom for that class (school.jpg) Any help why i can't have those values? Thanks
×
×
  • 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.