Jump to content

gmc1103

Members
  • Posts

    258
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Hi I'm having problems(no updates) in my databases using this code public function editMultiDocenteGrupo($idDocentes, $mudaGrupo){ try { $stmt = $this->db->prepare("UPDATE `esmaior_ca`.`professor` SET `teacher_grupo` = :teacher_grupo WHERE `idteacher` = :idteacher"); $myArray = explode(',', $idDocentes); foreach($myArray as $id=> $mudaGrupo){ $stmt->bindParam(':teacher_grupo', $mudaGrupo, PDO::PARAM_INT); $stmt->bindParam(':idteacher', $id, PDO::PARAM_STR); if (!$stmt->execute()) { print_r($stmt->errorInfo()); return array('status' => 'error', 'message' => 'Opppss...no updates..'); } else { return array('status' => 'success', 'message' => 'All changes updated...'); } } } catch (PDOException $e) { echo $e->getMessage(); } } The array is this one when i user print_r Array ( [0] => 343 [1] => 256 [2] => 245 [3] => 265 [4] => 287 [5] => 201 [6] => 210 [7] => 275 [8] => 271 [9] => 260 ) i receive the success message but no changes are registered in the table Any help?
  2. Hi Barand So, do you suggest to have a foreign key between "apoio" and "timetable"?
  3. Hi Barand Ok, let me try to clarify everything This is a school management system. Teachers have timetable Timetable have teachears, students and subject I need to for every teachers timetable to have a lesson. So, if my season starts on september and i have 35 school weeks, i must "give" 35 lessons, so must store 35 lessons in database. To do so, today, regarding my timetable, i have classe between 2 PM and 4 PM, so after or during the class time i must be able to fill that form( regarding the plan lesson, missing students, etc), but if i forgot to do it, i want to have a warning to remember that lesson x has not been registered. To avoid any confusion...this is my sql script Hope now it can be clear.. esmaior_ca.zip
  4. Hi Barand The data is inserted into the database, this table "apoios" CREATE TABLE `apoios` ( `idtimetable` int(11) NOT NULL AUTO_INCREMENT, `sala_id` int(11) NOT NULL, `data` date NOT NULL, `inicio_id` time NOT NULL, `grupo` time NOT NULL, `teacher_sub_teacher_idteacher` int(11) NOT NULL, `teacher_sub_subject_idsubject` int(11) NOT NULL, `teacher_sub_turma_idturma` int(11) NOT NULL, PRIMARY KEY (`idtimetable`), KEY `fk_timetable_teacher_sub1_idx` (`teacher_sub_teacher_idteacher`,`teacher_sub_subject_idsubject`,`teacher_sub_turma_idturma`), KEY `sala_id` (`sala_id`), CONSTRAINT `apoios_ibfk_1` FOREIGN KEY (`sala_id`) REFERENCES `salas` (`idsala`), CONSTRAINT `fk_timetable_teacher_sub1` FOREIGN KEY (`teacher_sub_teacher_idteacher`, `teacher_sub_subject_idsubject`, `teacher_sub_turma_idturma`) REFERENCES `prof_disc` (`teacher_idteacher`, `subject_idsubject`, `turma_idturma`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEF This is the table where the data inserted in the form will be saved. My main issue here is this table CREATE TABLE `timetable` ( `id_timetable` int(11) NOT NULL AUTO_INCREMENT, `id_grupo` int(11) NOT NULL, `id_dia` int(11) NOT NULL, `id_tempo` int(11) NOT NULL, `id_prof` int(11) NOT NULL, PRIMARY KEY (`id_timetable`), KEY `id_grupo` (`id_grupo`), KEY `id_dia` (`id_dia`), KEY `id_tempo` (`id_tempo`), CONSTRAINT `timetable_ibfk_1` FOREIGN KEY (`id_grupo`) REFERENCES `grupos` (`id_grupos`), CONSTRAINT `timetable_ibfk_2` FOREIGN KEY (`id_dia`) REFERENCES `dias` (`id_dia`), CONSTRAINT `timetable_ibfk_3` FOREIGN KEY (`id_tempo`) REFERENCES `tempos` (`id_tempo`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; This is my timetable table where i have all classes scheduled. So, between those two tables how i can check if teacher A has filled the form for hhis scheduled classes? Thanks
  5. Hi Barand Sorry for not be so clear as i should. Well, in every classe the teacher must insert into the datatable the subject of the classe, for example if i have a classe of math on monday at 12:00, i must fill in a form the following data Subject Data Classe Missing Student Somy question is, how can i prevent a teacher of not fill the form...since every week (monday) i have this classe and he must fill that form every monday? Thanks
  6. Hi I need some advices and help regarding this database. This is what i have so far with all tables necessary This is a school timetable where the teachers must register the class summary My main problem is this: Every monday there is classes....so every teacher must register the summary, how do i know from timetable table and "apoios" table is the summary has been registered? Thanks
  7. gmc1103

    Query help

    Hi I'm trying to run a query but is not giving me the right values i need I need to run a query to have all classes ordered and the names of that classes ASC Example Class A have 20 students Class B have 18 So my query would have to give me A Names ASC B Names ASC etc This is what i have but with no success SELECT t1.`idstudent`, t1.`nome`, t1.`numero`, t1.`inscrito`, t1.`estado`, t1.`processo`, t2.`turma` FROM `esmaior_ca`.`alunos` AS t1 INNER JOIN `esmaior_ca`.`turma` AS t2 ON (t1.`turma_idturma` = t2.`idturma`) ORDER BY t2.`turma` AND t1.`nome` ASC; Any help?
  8. Hi Barand Yes it does, i made from the related tables but your examples seems to be better. I think it covers all needs regarding having a database to store all fields. Thank you again and have a nice week-end.
  9. Hi I have followed the user "Barand" implementation and i have another tables to uses Now i must uses another tables to make this database even more reliable I must add to an user the subject class, i mean, user A can teach Mats A and Maths B, user B can teach English and French So i create a table "users_disc" where i use foreign keys from table user and table "esmaior_disc" And the "esmaior_disc" where i have the subjects class must have a year where they belongnew All the new schema are in red Any suggestions?
  10. I have fixed using if($val!=null){ try { $sql = "SELECT t1.`user_proc`, t1.`user_name` FROM `esmaior_alunos` as t1 INNER JOIN `esmaior_turma` as t2 ON (t1.`user_id_ano_turma` = t2.`id_turma`) WHERE (t2.`id_turma` = :val);"; $query = $DB_con->prepare($sql); $query->bindparam(":val", $val); $query->execute(); $result = $query->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $row) { echo "<option value='{$row['user_proc']}'>{$row['user_name']}</option>\n"; } } catch (PDOException $e) { echo $e->getMessage(); } } and the ajax <script> $(document).on("change", '#turma', function(e) { var turmas = $(this).val(); $.ajax({ type: 'post', url: 'classes/getFromDatabase.php', data: {get_option:turmas}, dataType: 'html', success: function(resposta) { console.log(resposta); document.getElementById("alunos").innerHTML=resposta; } }); }); </script> For those with same problem
  11. Thank you for helping me I have removed that but i still have the same problem, i receive this in my php Array ( [data] => 2016-02-12 [hora] => 12:12 [ati] => fertertert [turma] => 17 [alunos] => Array ( [0] => 1 [1] => 4 [2] => 5 ) [docente] => 88 ) And [alunos] don't have the user_proc number wich is by that order 15497 15789 15805 and i receive 1, 4 and 5 So i need pass to <option value "user_proc">user_name> to get the correct values in my database
  12. Hi I have a select dropdown where the user select an item and the second dropdown shows the options in multiple select options. From my database i have $val = filter_input(INPUT_POST, 'get_option'); if($val!=null){ try { $sql = "SELECT t1.`user_proc`, t1.`user_name` FROM `esmaior_alunos` as t1 INNER JOIN `esmaior_turma` as t2 ON (t1.`user_id_ano_turma` = t2.`id_turma`) WHERE (t2.`id_turma` = :val);"; $query = $DB_con->prepare($sql); $query->bindparam(":val", $val); $query->execute(); $result = $query->fetchAll(PDO::FETCH_ASSOC); echo json_encode($result); } catch (PDOException $e) { echo $e->getMessage(); } } And i get the result here <script> $(document).on("change", '#turma', function(e) { var turmas = $(this).val(); $.ajax({ type: 'post', url: 'classes/getFromDatabase.php', data: {get_option:turmas}, dataType: 'json', success: function(resposta) { var $el = $("#alunos"); $el.empty(); var nomes = resposta.map( function( el ){ var processo = []; processo.push(el.user_proc); for (var i = 0; i < processo.length; i++) { getNumerosProcessos(processo); } return el.user_name; }); $.each(nomes, function(value, key) { $el.append($("<option></option>").attr("value", value).text(key)); }); } }); }); </script> This is working but the main problem it's i have to get the "user_proc" into my multiple select option value but i can't have that since this is dynamic My select is this <div class="form-group"> <label for="exampleInputFile">Alunos Ausentes (tecla "shift" para seguidos, "ctrl" para separados)</label> <select name="alunos[]" id="alunos[]" class="form-control" multiple title="Escolha os alunos" style="height: 240pt;"> <option value=""></option> </select> </div> So with this code how i can pass to <option value "user_proc">Name> any help? Thanks
  13. Hi Barand, i will try to implement your schema. Any doubt i will open a new topic Thank you again.
  14. What i have so far is Table class CREATE TABLE `esmaior_turma` ( `id_turma` int(11) NOT NULL AUTO_INCREMENT, `turma` varchar(100) COLLATE utf8_bin NOT NULL, `estado` tinyint(1) NOT NULL, PRIMARY KEY (`id_turma`) ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COLLATE=utf8_bin and table students Create Table CREATE TABLE `esmaior_alunos` ( `id_aluno` int(11) NOT NULL AUTO_INCREMENT, `user_proc` int(11) NOT NULL, `user_name` varchar(200) COLLATE utf8_bin NOT NULL, `user_id_ano_turma` int(11) NOT NULL, `user_num_turma` int(20) NOT NULL, PRIMARY KEY (`id_aluno`), KEY `user_id_ano_turma` (`user_id_ano_turma`), CONSTRAINT `esmaior_alunos_ibfk_1` FOREIGN KEY (`user_id_ano_turma`) REFERENCES `esmaior_turma` (`id_turma`) ) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_bin Now i need to think about a table where i can insert records by id_user, what i pretend to to is: When the teacher add new record, he select the class, then select all the students (user_id) presents of that classes and when i make a query by user_id i can check all the lessons he went..
  15. Can a student belong to more than one class? No, a student belong to one class only (ex 10ºA) Can a student have more than one private lesson? Yes but not in same time (Ex can have English, Maths in different hours time) Can a class have more than one one private lesson? yes (One private lesson can have class A and B and more)
  16. Hi I would to have some opinions about a new task i have regarding inserting records into database This is school scenario The school has private lessons and the principal wants to know wich students going to get in the end of the year a full report The students belongs to class The private lessons can have several classes So when i will insert records into database wich approach i must follow 1- Insert by class then choose every student of that class 2- Insert by students and then by student id i can get his class 3- another one Thank you for any opinion
  17. Hi Barand Thank you again. Best regards
  18. I have this table Field Type Comment idsala int(11) NOT NULL sala varchar(45) NOT NULL estado tinyint(1) NOT NULL And i want to avoid 3 records from the database I'm using this query but those records are showed SELECT `idsala` , `sala` FROM `req_material_sala` WHERE (`idsala` !=23) OR (`idsala` !=24) OR (`idsala` !=39); Any help please?
  19. Hi I'm trying to use the followwing code to get the user name but i need also the user_id. The code is the following <script type="text/javascript"> function autocomplet() { var min_length = 2; var keyword = $('#nome_id').val(); if (keyword.length >= min_length) { $.ajax({ url: 'getFromDB/getFromDatabase.php', type: 'POST', data: {keyword:keyword}, success:function(data){ $('#nome_list_id').show(); $('#nome_list_id').html(data); } }); } else { $('#nome_list_id').hide(); } } function set_item(item) { $('#nome_id').val(item); $('#nome_list_id').hide(); } </script> and in my pdo i have this $keyword = '%'.$_POST['keyword'].'%'; if ($keyword!= null) { $sql = "SELECT * FROM utilizador WHERE nome LIKE (:keyword) and estado = 1 ORDER BY idutilizador ASC LIMIT 0, 10"; $query = $DB_con->prepare($sql); $query->bindParam(':keyword', $keyword, PDO::PARAM_STR); $query->execute(); $list = $query->fetchAll(); foreach ($list as $rs) { $nome = str_replace($_POST['keyword'], '<b>'.$_POST['keyword'].'</b>', $rs['nome']); $iduser = $rs['idutilizador']; echo '<li onclick="set_item(\''.str_replace("'", "\'", $rs['nome']).'\')">'.$nome.'</li>'; } } In the following line i need to pass the variable $iduser echo '<li onclick="set_item(\''.str_replace("'", "\'", $rs['nome']).'\')">'.$nome.'</li>'; any help?
  20. Hi again With this code require_once "{$_SERVER['DOCUMENT_ROOT']}/include/membersite_config.php"; i have this error Warning: require_once(/home/ebspma/public_html/include/membersite_config.php): failed to open stream: No such file or directory in /home/ebspma/public_html/gesdocente/admin_pages/adminAtividadesByMonthChart.php on line 4 Wtis this code require_once "{$_SERVER['DOCUMENT_ROOT']}../include/membersite_config.php"; I have this error too Warning: require_once(/home/ebspma/public_html../include/membersite_config.php): failed to open stream: No such file or directory in /home/ebspma/public_html/gesdocente/admin_pages/adminAtividadesByMonthChart.php on line 4 So, i think there is somthing wrong This is my code <?PHP error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once "{$_SERVER['DOCUMENT_ROOT']}../include/membersite_config.php"; if (!$ebspma->CheckLogin()) { $ebspma->RedirectToURL("index.php"); exit; } include '../menus/menus.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>EBSPMA - Gráfico</title> <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <link href="../css/bootstrap-table.css" rel="stylesheet" type="text/css"/> <link href="../css/bootstrap-editable.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" href="../css/formValidation.min.css"> </head> <body> <div class="row"> <div class="col-md-12"> <div class="row clearfix"> <div class="col-md-12 column"> <div class="alert alert-info"><h3>Atividades por meses</h3></div> </div> </div> <div class="col-md-2"></div> <div class="col-md-8" id="visualization" style="width: 800px; height: 400px;"></div> <div class="col-md-2"></div> <?php include 'mysqliconn.php'; $query = "SELECT idativade, DATE_FORMAT(data, '%b') AS Datas, COUNT( * ) AS Atividades FROM `ebspma_paad_ebspma`.`nem_pae_atividades` GROUP BY Datas ORDER BY data"; $result = $mysqli->query($query); $num_results = $result->num_rows; if ($num_results > 0) { ?> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {'packages': ['corechart', 'geochart', 'table']}); </script> <script type="text/javascript"> function drawVisualization() { // Create and populate the data table. var data = google.visualization.arrayToDataTable([ ['Datas', 'Atividades'], <?php while ($row = $result->fetch_assoc()) { extract($row); echo "['{$Datas}', {$Atividades}],"; } ?> ]); new google.visualization.ColumnChart(document.getElementById('visualization')). draw(data, {title: "Distribuição Mensal"}); } google.setOnLoadCallback(drawVisualization); </script> <?php } else { echo "Sem atividades registadas"; } ?> </div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="../js/formValidation.min.js"></script> <script src="../js/bootstrap.min.js"></script> <script src="../js/bootstrap.min2.js"></script> <script src="../js/bootstrap-table.js"></script> <script src="../js/bootstrap-table-export.js"></script> <script src="../js/bootstrap-table-pt-PT.js"></script> <script type="text/javascript" src="../js/tableExport.js"></script> <script type="text/javascript" src="../js/jquery.base64.js"></script> <script type="text/javascript" src="../js/sprintf.js"></script> <script type="text/javascript" src="../js/jspdf.js"></script> <script type="text/javascript" src="../js/base64.js"></script> </body> </html>
  21. No...it gives me that error Warning: require_once(/home/ebspma/public_html../include/membersite_config.php): failed to open stream: No such file or directory in /home/ebspma/public_html/gesdocente/admin_pages/adminAtividadesByMonthChart.php on line 4
  22. Hi I'm having a problem regarding this function I have a folder (admin_pages) who have inside a file, that file should call another file inside a root folder i have tried require_once("../include/membersite_config.php"); And it gives me error Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/ebspma/public_html/gesdocente/include/membersite_config.php on line 2 This is my structure any help to get into include folder from admin_pages file folder? Thanks
  23. Hi This is what i have with phpinfo(); MysqlI Support enabled Client API library version 5.5.46 Active Persistent Links 0 Inactive Persistent Links 0 Active Links 0 Client API header version 5.5.45 MYSQLI_SOCKET /var/lib/mysql/mysql.sock Directive Local Value Master Value mysqli.allow_local_infile On On mysqli.allow_persistent On On mysqli.default_host no value no value mysqli.default_port 3306 3306 mysqli.default_pw no value no value mysqli.default_socket no value no value mysqli.default_user no value no value mysqli.max_links Unlimited Unlimited mysqli.max_persistent Unlimited Unlimited mysqli.reconnect Off Off Regarding the code i'm changing to pdo, but i have problems regarding the password match I'm using this public function getUserByEmailAndPassword($email, $password) { $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = :email"); $stmt->bindparam(":email", $email); if ($stmt->execute()) { $user = $stmt->fetch(); $salt = $user['salt']; $encrypted_password1 = $user['encrypted_password']; echo $encrypted_password1; $hash = $this->checkhashSSHA($salt, $password); if ($encrypted_password1 == $hash) { return $user; } } else { return NULL; } } But $user is always empty Thanks
  24. Sorry Current PHP version: 5.5.302.0
  25. Variable_name Value ----------------------- ------------------------------ innodb_version 5.5.46 protocol_version 10 slave_type_conversions version 5.5.46-cll version_comment MySQL Community Server (GPL) version_compile_machine x86_64 version_compile_os Linux I must check how to use PDO in that case, do you have an example?
×
×
  • 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.