Jump to content

gmc1103

Members
  • Posts

    251
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Hi Thank you for your answer, i'm foloowing this example and it seems to be what i need but i'm having an issue $a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]; $c = array_fill_keys(array_keys(array_diff($a,$hora)),null) + $a; ksort($c); foreach ($c as $key => $val) { $stmt = $mysqli->prepare("INSERT INTO `ebspma`.`sala_ocupacao` (id_dia, id_sala, id_tempo) VALUES (?, ?, ?);")or die(mysql_error($mysqli)); $horas = $val; echo $mysqli->error, PHP_EOL; $stmt->bind_param('ssi', $dia, $sala, $horas); if(!$stmt->execute()) echo $stmt->error; $response = "Registo gravado"; echo json_encode($response); $stmt->close(); But instead of writing to the bd the values of teh array $c....the loop is executed more than 1000 times.. This is what a i get from my debuger http://postimg.org/image/739yp0qfr/ What's wrong after the ksort?
  2. Hi I have an for examplo {1,2,3,4,5,6,7,8,9,10}and another one from a fprm {1,4,7,9,10} , i would like to compafe both and create a new one with null where there are differences.. any help? Thanks
  3. Hi I have this code <?PHP error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once("./include/membersite_config.php"); if (!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("index.php"); exit; } if (isset($_POST['submitted'])) { if($fgmembersite->ChangePassword()){ sleep(2); $success="A mudança de password foi efetuadada...."; $fgmembersite->RedirectToURL("index.php"); } else{ $success="A mudança de password não foi efetuadada....tente mais tarde"; } } ?> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>EBSPMA Atividades</title> <link href="css/styles.css" rel="stylesheet"> <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="js/modernizr.js?cb=2.2.3.2085"></script> <script type="text/javascript"> </script> </head> <body> <header role="banner" class="main-header"> <!-- MAIN HEADER --> <div class="main-header-body"> <div class="container-wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-xs-3"> <h2> PAAD-Atividades</h2> </div> <div class="col-xs-4 col-xs-offset-1 main-header-title"> <p class="sizeToggle" >Mudar Password</p> </div> </div> </div> </div> </div> </header><section class="content"> <div class="grid"> <div class="box"> <form name="changepwd" id="loginForm" action='<?php echo $fgmembersite->GetSelfScript(); ?>' method="POST"> <input type="hidden" name='submitted' id='submitted'/> <input type="hidden" name="path" value="painelAdquirente.action"/> <div> <p><b><font color="red">A sua password deve ser alterada!</font></b></p></div> <div class="icon-input"> <label for="password"></label> <div class="input password"> <i class="fa fa-lock"></i> <input type="password" name="oldpwd" id="oldpwd" placeholder="Senha antiga"> </div> </div> <br> <div class="icon-input"> <label for="password"></label> <div class="input password"> <i class="fa fa-lock"></i> <input type="password" name="newpwd" id="newpwd" placeholder="Senha nova"> </div> <input type="hidden" name="email" id="email" value="<?php echo $fgmembersite->UserEmail(); ?>"> </div> <br> <input type="submit" id="sbmtLogin" class="sa-btn1" value="Mudar"> </form> </div> <div id="panel"> <div id="success"></div> </div> <div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div> </div> </section> <script src="js/jquery-1.11.1.min.js"></script> <script src="js/jquery.validate.min.js"></script> <script src="js/plugins.js?cb=2.2.3.2085"></script> </body> </html> How to put a div where i can have the result of my function
  4. Hi I'm having a problem with this error This is my code <?PHP error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("index.php"); exit; } if($fgmembersite->UserId() == 1261){ $fgmembersite->RedirectToURL("testes.php"); exit; } $userid = $fgmembersite->UserId(); ?> And the result is a lot of testes.php until i get that error my chrome debug gives me this Request URL: http://testes.php Request Headers Provisional headers are shown Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36 Any help
  5. Hi No, it was a double quote error...sorry Thanks
  6. Thank you The first error has gone but i still have the second <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $iduser= $_GET['userid']; include 'conn.php'; mysql_query("SET NAMES 'utf8'"); $rs = mysql_query('SELECT `pae_atividades`.`idativade` , `pae_cargo`.`cargo` , `pae_atividades`.`atividade` , `pae_atividades`.`data` , `pae_atividades`.`hora` , `pae_atividades`.`local` , `pae_atividades`.`inter` , `pae_atividades`.`notas` , `utilizador`.`nome` FROM `ebspma_paad_ebspma`.`pae_atividades` INNER JOIN `ebspma_paad_ebspma`.`utilizador` ON ( `pae_atividades`.`idutilizador` = `utilizador`.`idutilizador` ) INNER JOIN `ebspma_paad_ebspma`.`pae_cargo` ON ( `pae_atividades`.`idcargo` = `pae_cargo`.`idcargo` ) WHERE `pae_atividades`.`data` >= CURDATE( ) AND `pae_atividades`.`idutilizador`= $iduser ORDER BY `pae_atividades`.`data` ASC '); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?> Line 14 Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/ebspma/public_html/atividades/get_atividadesByUserId.php on line 14 []
  7. Hi Can someone help me with this <table id="dg" class="easyui-datagrid" url="get_atividadesByUserId.php?=<?php echo $userid ?>" style="width:1800px;height:500px; border:1px solid #ccc;" title="Gestão das Atividades" toolbar="#toolbar" pagination="true" idField="id" rownumbers="true" fitColumns="true" resizable="true"> <thead> <tr> <th field="idativade" width="20">Nº</th> <th field="cargo" width="200">Cargo</th> <th field="atividade" width="200">Atividade</th> <th field="data" width="50">Data</th> <th field="hora" width="50">Hora</th> <th field="local" width="100">Local</th> <th field="inter" width="200">Intervenientes</th> <th field="notas" width="150">Notas</th> </tr> </thead> </table> and my php <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $iduser= $_GET['userid']; include 'conn.php'; mysql_query("SET NAMES 'utf8'"); $rs = mysql_query('SELECT `pae_atividades`.`idativade` , `pae_cargo`.`cargo` , `pae_atividades`.`atividade` , `pae_atividades`.`data` , `pae_atividades`.`hora` , `pae_atividades`.`local` , `pae_atividades`.`inter` , `pae_atividades`.`notas` , `utilizador`.`nome` FROM `ebspma_paad_ebspma`.`pae_atividades` INNER JOIN `ebspma_paad_ebspma`.`utilizador` ON ( `pae_atividades`.`idutilizador` = `utilizador`.`idutilizador` ) INNER JOIN `ebspma_paad_ebspma`.`pae_cargo` ON ( `pae_atividades`.`idcargo` = `pae_cargo`.`idcargo` ) WHERE `pae_atividades`.`data` >= CURDATE( ) AND `pae_atividades`.`idutilizador`= $iduser ORDER BY `pae_atividades`.`data` ASC '); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?> I'm getting this error <br /> <b>Notice</b>: Undefined index: userid in <b>/home/ebspma/public_html/atividades/get_atividadesByUserId.php</b> on line <b>4</b><br /> <br /> <b>Warning</b>: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in <b>/home/ebspma/public_html/atividades/get_atividadesByUserId.php</b> on line <b>14</b><br /> [] The url passed is right get_atividadesByUserId.php?=1261 i have the id correct so whats wrong? Thanks
  8. Hi Thank for your help Doesn't work This is my full php file <?PHP require_once("./include/membersite_config.php"); $userid = $fgmembersite->UserId(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="keywords" content="ebspma, atividades, registar, alterar, apagar"> <meta name="description" content="ebspma, atividades, registar, alterar, apagar"> <title>Gestão das Atividades Docentes</title> <link rel="stylesheet" type="text/css" href="css/easyui.css"> <link rel="stylesheet" type="text/css" href="css/icon.css"> <link rel="stylesheet" type="text/css" href="css/demo.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script> <script type="text/javascript" src="js/datagrid-filter.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script> <style type="text/css"> #fm{ margin:0; padding:20px 50px; } .ftitle{ font-size:14px; font-weight:bold; padding:10px 0; margin-bottom:10px; border-bottom:1px solid #ccc; } .fitem{ margin-bottom:15px; } .fitem label{ display:inline-block; width:120px; } .fitem input{ width:200px; } <style type="text/css"> #fm{ margin:0; padding:10px 30px; } .ftitle{ font-size:14px; font-weight:bold; padding:5px 0; margin-bottom:10px; border-bottom:1px solid #ccc; } .fitem{ margin-bottom:15px; } .fitem label{ display:inline-block; width:120px; } .fitem input{ width:200px; } .fitemdatahora{ margin-bottom:15px; } .fitemdatahora label{ display:inline-block; width:120px; } .fitemdatahora input{ width:100px; } </style> <script type="text/javascript"> $(function(){ $('#dg').datagrid({ view: detailview, detailFormatter:function(index,row){ return '<div class="ddv"></div>'; }, onExpandRow: function(index,row){ var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv'); ddv.panel({ border:false, cache:true, href:'show_form.php?index='+index, onLoad:function(){ $('#dg').datagrid('fixDetailRowHeight',index); $('#dg').datagrid('selectRow',index); $('#dg').datagrid('getRowDetail',index).find('form').form('load',row); } }); $('#dg').datagrid('fixDetailRowHeight',index); } }); }); function removeAtividade(){ var row = $('#dg').datagrid('getSelected'); if (row){ $.messager.confirm('Confirmar!!','Tem a certeza que deseja remover esta atividade?',function(r){ if (r){ var index = $('#dg').datagrid('getRowIndex',row); $.post({id:row.id},function(){ $('#dg').datagrid('deleteRow',index); }); $.post('remove_atividade.php',{id:row.idativade},function(result){ if (result.success){ $('#dg').datagrid('reload'); } else { $.messager.show({ // show error message title: 'Erro', msg: result.errorMsg }); } },'json'); } }); } } function saveAtividade(index){ var row = $('#dg').datagrid('getRows')[index]; var url = row.isNewRecord ? 'nova_atividade.php' : 'update_atividade.php?id='+row.idativade; $('#dg').datagrid('getRowDetail',index).find('form').form('submit',{ url: url, onSubmit: function(){ return $(this).form('validate'); }, success: function(data){ data = eval('('+data+')'); data.isNewRecord = false; $('#dg').datagrid('collapseRow',index); $('#dg').datagrid('updateRow',{ index: index, row: data }); } }); } function cancelItem(index){ var row = $('#dg').datagrid('getRows')[index]; if (row.isNewRecord){ $('#dg').datagrid('deleteRow',index); } else { $('#dg').datagrid('collapseRow',index); } } function novaAtividade(){ $('#dlg').dialog('open').dialog('setTitle','Registar Nova Atividade'); $('#fm').form('clear'); } function saveUser(){ $('#fm').form('submit',{ url: 'nova_atividade.php', onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval('('+result+')'); if (result.errorMsg){ $.messager.show({ title: 'Erro', msg: result.errorMsg }); } else { $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); } function populateCargo() { $.getJSON('t.php', {cargo:$('#cargo').val()}, function(data) { var select = $('#cargo_name'); var options = select.prop('options'); $('option', select).remove(); $.each(data, function(index, array) { options[options.length] = new Option(array['cargo']); }); }); } $(document).ready(function() { populateCargo(); $('#cargo').change(function() { populateCargo(); }); }); </script> <script type="text/javascript"> $('#data').datebox({ formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();}, parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));} }); </script> </head> <body> <div class="easyui-layout"> <h2 class="sub_title">Bem vindo <?= $fgmembersite->UserFullName(); ?> !</h2> <h2 class="sub_title">Bem vindo <?php echo $userid; ?> !</h2> <h2>Gestão das Atividades Docentes</h2> <div class="demo-info" style="margin-bottom:10px"> <div class="demo-tip icon-tip"> </div> <div>*Clique no sinal "+" numa linha para editar o registo.</div> </div> <table id="dg" class="easyui-datagrid" url="get_atividades.php" style="width:1800px;height:500px; border:1px solid #ccc;" title="Gestão das Atividades" toolbar="#toolbar" pagination="true" idField="id" rownumbers="true" fitColumns="true" resizable="true"> <thead> <tr> <th field="idativade" width="20">Nº</th> <th field="cargo" width="200">Cargo</th> <th field="atividade" width="200">Atividade</th> <th field="data" width="50">Data</th> <th field="hora" width="50">Hora</th> <th field="local" width="100">Local</th> <th field="inter" width="200">Intervenientes</th> <th field="notas" width="150">Notas</th> </tr> </thead> </table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="novaAtividade()">Nova</a> <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeAtividade()">Remover</a> </div> </div> <div id="dlg" class="easyui-dialog" style="width:800px;height:500px;padding:10px 20px" closed="true" buttons="#dlg-buttons"> <div class="ftitle">Nova Atividade</div> <form id="fm" method="post" novalidate> <div class="fitem"> <label>Cargo:</label> <select name="cargo" id="cargo_name"></select> </div> <div class="fitem"> <label>Atividade:</label> <input name="nome" required="true" class="easyui-textbox" size="60"> </div> <div class="fitemdatahora"> <label>Data:</label> <input name="data" class="easyui-datebox" id="data" size="30"> </div> <div class="fitemdatahora"> <label>Hora:</label> <input id="hora" class="easyui-timespinner" name="hora"> </div> <div class="fitem"> <label>Local:</label> <input name="local" class="easyui-textbox" required="true"> </div> <div class="fitem"> <label>Intervenientes:</label> <input name="inter" class="easyui-textbox" required="true"> </div> <div class="fitem"> <label>Notas:</label> <input name="notas" id="notas" size="60"> </div> <div class="fitem"> <input type="text" name='iduser' id='iduser' value="<?php echo $userid; ?>"> </div> </form> </div> <div id="dlg-buttons"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Registar</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancelar</a> </div> </body> </html> Outside the form i have the variable working. Inside the form....is blank I can populate the first <div class="fitem"> <label>Cargo:</label> <select name="cargo" id="cargo_name"></select> </div> with JavaScript function function populateCargo() { $.getJSON('t.php', {cargo:$('#cargo').val()}, function(data) { var select = $('#cargo_name'); var options = select.prop('options'); $('option', select).remove(); $.each(data, function(index, array) { options[options.length] = new Option(array['cargo']); }); }); } $(document).ready(function() { populateCargo(); $('#cargo').change(function() { populateCargo(); }); }); But i can't populate this one <div class="fitem"> <input type="text" name='iduser' id='iduser' value="<?php echo $userid; ?>"> </div> and i know the variable is not null...so what i'm doing wrong? Regards
  9. Hi I have this following code, i'm using easyui-datagrid and when i choose "new" it open a form you can see in the end of the code but the echo returns nothing. <?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } $userid = $fgmembersite->UserId(); ?> <body> <div class="easyui-layout"> <h2 class="sub_title">Bem vindo <?= $fgmembersite->UserFullName(); ?> !</h2> <h2>Gestão das Atividades Docentes</h2> <div class="demo-info" style="margin-bottom:10px"> <div class="demo-tip icon-tip"> </div> <div>*Clique no sinal "+" numa linha para editar o registo.</div> </div> <table id="dg" class="easyui-datagrid" url="get_atividades.php" style="width:1800px;height:500px; border:1px solid #ccc;" title="Gestão das Atividades" toolbar="#toolbar" pagination="true" idField="id" rownumbers="true" fitColumns="true" resizable="true"> <thead> <tr> <th field="idativade" width="20">Nº</th> <th field="cargo" width="200" editor="{type:'validatebox',options:{required:true}}">Cargo</th> <th field="atividade" width="200" editor="{type:'validatebox',options:{required:true}}">Atividade</th> <th field="data" width="50" editor="{type:'validatebox',options:{required:true}}">Data</th> <th field="hora" width="50" editor="{type:'validatebox',options:{validType:'hora'}}">Hora</th> <th field="local" width="100" editor="{type:'validatebox',options:{validType:'local'}}">Local</th> <th field="inter" width="200" editor="{type:'validatebox',options:{validType:'inter'}}">Intervenientes</th> <th field="notas" width="150">Notas</th> </tr> </thead> </table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="novaAtividade()">Nova</a> <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeAtividade()">Remover</a> <a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="saveAtividade()">Guardar</a> </div> </div> <div id="dlg" class="easyui-dialog" style="width:800px;height:500px;padding:10px 20px" closed="true" buttons="#dlg-buttons"> <div class="ftitle">Nova Atividade</div> <form id="fm" method="post" novalidate> <div class="fitem"> <label>Cargo:</label> <select name="cargo" id="cargo_name"></select> </div> <div class="fitem"> <label>Atividade:</label> <input name="nome" required="true" class="easyui-textbox" size="60"> </div> <div class="fitemdatahora"> <label>Data:</label> <input name="data" class="easyui-datebox" id="data" size="30"> </div> <div class="fitemdatahora"> <label>Hora:</label> <input id="hora" class="easyui-timespinner" name="hora"> </div> <div class="fitem"> <label>Local:</label> <input name="local" class="easyui-textbox" required="true"> </div> <div class="fitem"> <label>Intervenientes:</label> <input name="inter" class="easyui-textbox" required="true"> </div> <div class="fitem"> <label>Notas:</label> <input name="notas" id="notas" size="60"> </div> <div class="fitem"> <input type="text" name='iduser' id='iduser' value="<?= echo $fgmembersite->UserId(); ?>"> </div> </form> </div> <div id="dlg-buttons"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Registar</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancelar</a> </div> </body> </html> <input type="text" name='iduser' id='iduser' value="<?= echo $fgmembersite->UserId(); ?>"> The "echo" outside the form works, i have the userId, so what's wrong? Thanks
  10. gmc1103

    hello

    Hi I'm from Portugal and i'm learning php. I just found this site and i would like to learn from all of you. regards gmc
×
×
  • 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.