public function add_new_user($email, $nome, $ident, $curso) { include_once 'database.php'; $db = new avdb(); $res = array(); //echo "<br>****cadastra o novo usuário***<br>"; $nomea = str_replace("'", " ", $nome); $identa = str_replace("'", " ", $ident); if ($db->runINS("usuarios (\"Nome\", \"Mail\", \"Nivel\", \"Id\") VALUES( '{$nomea}', '{$email}', 2, '{$identa}')") == 1) { //inser o novo usuário no curso $res['idUser'] = $db->runSEL("\"Chave\" FROM usuarios WHERE \"Mail\" = '{$email}'"); //localiza o código do curso $res['codcur'] = $db->runSEL("\"Chave\" FROM cursos WHERE \"Nome\" = '{$curso}'"); $res['add'] = $db->runINS("curso_alunos (\"CodCurso\", \"CodUser\", \"Visto\") VALUES(" . $res['codcur'] . ", " . $res['idUser'] . ", 0)"); return $res; } }
function put_lista_cursos() { ?> <div align="center"> <table class="tabTitle"> <tr> <?php //exibe o nº de cursos cadastrados global $db; $db = new avdb(); $db->Conn_av(); //$sql = "SELECT COUNT(Chave)FROM cursos"; $res = pg_query("SELECT count_cursos('Chave')"); $r = pg_fetch_row($res); //echo "<br>contar de cursos=".$r[0]."<br>"; ?> <td><b><?php echo $r[0]; ?> cursos cadastrados</b></td> </tr> </table> <table class="tablemenu"> <tr> <td width="43" align="center" class="tdmenu"><b><font size="2" color="#FFFFFF">Id</b></td> <td align="left" class="tdmenu"><b>Curso</b></td> <td align="center" width="80" class="tdmenu"><b>Responsavel</b></td> <td align="center" width="40" class="tdmenu"> </td> </tr> </table> <table class="tabValores"> <?php $c1 = "#FFFFFF"; $c2 = "#CCCCCC"; $class1 = "botaobco"; $class2 = "botaocinza"; $c = 0; $class = 0; //$inicio10 = $inicio + 100; //echo "<br> SELECT Chave, Nome, Responsavel FROM cursos ORDER BY Chave DESC LIMIT $inicio , $inicio10"; $res = $db->runSEL('lista_cursos()'); //var_dump($res); //echo "<br>".$res; foreach ($res as $r) { //while($r == pg_fetch_array($res)) { //echo $r; tr bgcolor=".(($c++&1)?$c1:$c2)." echo "<tr bgcolor=\"" . ($c++ & 1 ? $c1 : $c2) . "\"> <td width=\"43\">" . $r['chave'] . "</td> \r\n <form id=\"Exp\" name=\"Exp\" method=\"post\">\r\n <input type=\"hidden\" name=\"codCurso\" value=\"" . $r['chave'] . "\" />\r\n <td align=\"left\">\r\n <input name=\"OdimExporta\" type=\"submit\" value=\"" . $r['nome'] . "\" class=\"" . ($class++ & 1 ? $class1 : $class2) . "\" />\r\n </td>\r\n </form>\r\n <td width=\"80\" align=\"center\">" . $r['responsavel'] . "</td>\r\n <form id=\"EditaCurso\" name=\"EditaCurso\" method=\"post\">\r\n <td width=\"40\" align=\"center\"> \r\n <input type=\"submit\" class=\"btnEdita\" name=\"EditaCurso\" title=\"Editar Curso\" alt=\"Edita Curso\" value=\"{$r['chave']}\"> \r\n </td>\r\n </form>\r\n </tr>"; } ?> </table> </div> <div align="center"> </table> <table class="tabTitle"> <form id="MoreCursos" name="Morecursos" method="post" action=""> <tr><td align="right"> <!-- <input name="MoreCursos" type="submit" id="MoreCursos" value="Mais 100" class="botaoOdim" /> --> </form> </td></tr> </table> <table class="tblinha"> <tr> <td> </td> </tr> </table> </div> </div> </div> <?php }