
portugueseGuy
Membros-
Total de itens
9 -
Registro em
-
Última visita
Tudo que portugueseGuy postou
-
O problema está na comparação, ele mete todas seleccionadas e so o que tem id 10 e que deveria ficar seleccioanda <? mysql_connect("localhost","root","pass"); mysql_select_db("projecto"); $query = "SELECT * FROM doencas "; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $query2 = "SELECT * FROM atleta_doenca where id_dadosm ='10'"; $result2 = mysql_query($query2); ?><html> <head> <title>Teste</title> <style type="text/css"> #principal{ width: 500px; } .divCheckbox{ float: left; width: 140px; height: 21px; } </style> </head> <body> <form id="formulario" method="post" action="teste.php"> <fieldset id="principal"> <?php //echo $row2['id_atleta']; while($row2 = mysql_fetch_array($result2)) { while($row = mysql_fetch_array($result)) { echo $row['id']; $br = ""; $br = ($x%4==0)?"<br/>":""; echo(" <div class='divCheckbox'> <input type='checkbox' id='checkbox$x' name='checkbox$x' if(".$row['id']." ==".$row2['id_doenca']."){echo 'checked';} /> <label>".$row['id']."</label> $br </div> "); }} ?> </fieldset> </form> </body> </html>
-
a tabela onde guarda as escolhas seleccionadas tem dois atributos : id_user | id_ escolha ambos do tipo inteiro
-
Supondo que tenho a tabela utilizador, com os dados deste, e a tablea escolha que irá alimentar as checkboxes, depois tenho a tabela user_escolha onde estão as checkboxes que o atleta escolhe. so que não estou a conseguir por "checked" as checkbox através dessa terceira tabela.alguma dica? <?php $query = "SELECT * FROM escolha"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $query2 = "SELECT * FROM escolha where id_user ='10'"; $result2 = mysql_query($query); while($row = mysql_fetch_array($result)) { while($row2 = mysql_fetch_array($result2)) { $br = ""; $br = ($x%4==0)?"<br/>":""; echo(" <div class='divCheckbox'> <input type='checkbox' id='checkbox$x' name='checkbox$x' if(".$row['id']." ==".$row2['id_escolha']."){echo 'checked=checked';} /> <label>".$row['escolha']."</label> $br </div> "); }} ?>
-
agora estou com outro problema: tenho a tabela utilizador, com os dados deste, e a tablea escolha que irá alimentar as checkboxes, depois tenho a tabela user_escolha onde estão as checkboxes que o atleta escolhe. so que não estou a conseguir por "checked" as checkbox através dessa terceira tabela.alguma dica? mysql_connect("localhost","root","pass"); mysql_select_db("pass"); $query = "SELECT * FROM escolha"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $query2 = "SELECT * FROM escolha where id_user ='10'"; $result2 = mysql_query($query); ?><html> <head> <title>Teste</title> <style type="text/css"> #principal{ width: 500px; } .divCheckbox{ float: left; width: 140px; height: 21px; } </style> </head> <body> <form id="formulario" method="post" action="teste.php"> <fieldset id="principal"> <?php while($row = mysql_fetch_array($result)) { while($row2 = mysql_fetch_array($result2)) { $br = ""; $br = ($x%4==0)?"<br/>":""; echo(" <div class='divCheckbox'> <input type='checkbox' id='checkbox$x' name='checkbox$x' if(".$row['id']." ==".$row2['id_escolha']."){echo 'checked=checked';} /> <label>".$row['escolha']."</label> $br </div> "); }} ?> </fieldset> </form> </body> </html>
-
Funcionou perfeitamente! mt obrigado! <fieldset id="principal"> <?php while($row = mysql_fetch_array($result)) { // for($x=1; $x<=$num_rows; $x++){ $br = ""; $br = ($x%4==0)?"<br/>":""; echo(" <div class='divCheckbox'> <input type='checkbox' id='checkbox$x' name='checkbox$x'/> <label>".$row['escolha']."</label> $br </div> "); }//} ?> </fieldset>
-
peço desculpa por não me ter explicado bem, em anexo coloco uma imagem... o problema é que consoante a palavra for maior ou menor já não ficam alinhadas , mas para melhor explicar vai aqui esquema: como fica à esquerda, como desejava, à direita!
-
desculpa, postei o codigo errado. o que pretendo é apenas as checkbox, não os outros campos queria assim: checkbox 1 checkbox 2 checkbox 3 checkbox 4 checbox 5 checbox 6 é possivel? <?php mysql_connect("localhost","root","pass"); mysql_select_db("pass"); $query_siseg=mysql_query("SELECT * FROM escolhas ORDER BY id"); ?> <table style="font: 10px verdana;" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody><tr> <?php while($row=mysql_fetch_array($query_siseg)){ ?><td width="250"><?php while($row=mysql_fetch_array($query_siseg)){ ?> <input type="checkbox" name="id[]" value="<?php echo $row['id']; ?>"/> <?php echo $row['doenca'];?> <?php }; } ?>
-
Encontrei este script que alimenta as checkbox da pagina com os valores da base de dados, no entanto não consigo fazer com que fiquem alinhadas como as que fazemos à mão, alguém tem alguma sugestão? neste script ficam toda sem linha recta. pretendia que ficassem assim: check 1 check2 check3 check 3 Chk4 Chk5 <?php require ('get_connected.php'); $sql = "SELECT * FROM canada"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { } } ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>NAME:</td> <td>YEAR:</td> <td>MAKE:</td> <td>MODEL:</td> <td>VIN:</td> <td>LETTER SENT:</td> </tr> <?php while($row = mysql_fetch_array($result)) { echo "<tr> <td>" . $row['first_name'] . " " . $row['$last_name'] . "</td> <td>" . $row['vehicle_year'] . "</td> <td>" . $row['vehicle_make'] . "</td> <td>" . $row['vehicle_model'] . "</td> <td>" . $row['vin'] . "</td> <td><input name='letter_sent' type='checkbox' value='" . $row['letter_sent'] . "' /></td> </tr>"; } ?> </table>
-
o facto de ter o import de estes dois ficheiros está a causar confusão entre duas funcionalidades ajax, num documento php alguém sabe qual o motivo? <script src="tabs_ficheiros/jquery.js" type="text/javascript"></script> <script src="calendario/development-bundle/jquery-1.4.2.js"></script> aqui esta a pagina! alguém me pode ajudar por favor? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/ <link href="../css/estilo.css" rel="stylesheet" type="text/css" /> <link href="../css/menu_style.css" rel="stylesheet" type="text/css" /> <!--tab--> <link href="estilotab.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="tabs_ficheiros/tabs.css" type="text/css" media="projection, screen"> <script src="tabs_ficheiros/jquery.js" type="text/javascript"></script> <script src="tabs_ficheiros/tabs.js" type="text/javascript"></script> <!-- Additional IE/Win specific style sheet (Conditional Comments) --> <!--[if lte IE 7]> <link rel="stylesheet" href="tabs-ie.css" type="text/css" media="projection, screen" /> <![endif]--> <!-- Additional IE/Win specific style sheet (Conditional Comments) --> <!--[if lte IE 7]> <style type="text/css" media="screen, projection"> body { font-size: 100%; /* resizable fonts */ } </style> <![endif]--> <script type="text/javascript"> $(document).ready(function() { $.tabs("container"); }); </script> <!-- fim tab--> <!--calendario --> <link rel="stylesheet" href="calendario/development-bundle/themes/base/jquery.ui.all.css"> <script src="calendario/development-bundle/jquery-1.4.2.js"></script> <script src="calendario/development-bundle/ui/jquery.ui.core.js"></script> <script src="calendario/development-bundle/ui/jquery.ui.widget.js"></script> <script src="calendario/development-bundle/ui/jquery.ui.datepicker.js"></script> <link rel="stylesheet" href="calendario/development-bundle/demos/demos.css"> <script> $(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true }); }); </script> <script> $(function() { $( "#datepicker2" ).datepicker({ changeMonth: true, changeYear: true }); }); </script> <!-- fim calendario calendario --> </head> <body> <div id="cabeçalho"> </div> <div id="corpo"> <div id="menuSimples"> </div> <CENTER> <h3><b><font color="#FF6600">Registo de Alunos</font></b></h3> <?php function MostrarFormulario() { ?> <!-- Formulário de login --> <form action="" method="POST"> <div id="container"> <ul class="anchors"> <li class="on"><a href="#Dados-Pessoais">Dados Pessoais</a></li> <li><a href="#Dados-Escolares">Dados Escolares</a></li> <li><a href="#Dados-Tecnicos">Dados Técnicos</a></li> <li><a href="#Dados-Medicos">Dados Médicos</a></li> </ul> <div id="Dados-Pessoais" class="anchor"> <center> <table border="0" cellpadding="10" cellspacing="0" id="c_table"> <TR> <td valign="top" class="generalText">Nome</td> <td valign="top" width="136" class="generalText"> <input type="text" name="nome" maxlength="25" /></td> </TR> <TR><td valign="top" class="generalText">Sexo</td><TD> <input type="radio" name="sexo" value="Masculino"> Masculino<br> <input type="radio" name="sexo" value="Feminino" checked> Feminino<br> </TD> </TR> <TR> <td valign="top" class="generalText">Data de Nascimento</td> <td> <input type="text" id="datepicker"> </td> </TR> <TR> <td valign="top" class="generalText">Número de BI</td> <td valign="top" width="136" class="generalText"><input type="text" name="numerobi" maxlength="10" /></td> </TR> <TR> <td valign="top" class="generalText">Arquivo</td> <td valign="top" width="136" class="generalText"><input type="text" name="arquivo" maxlength="10" /></td> </TR> <TR> <td valign="top" class="generalText">Data de Validade</td> <td> <input type="text" id="datepicker2"> </td> </TR> </center> </table> <br><br><br><br> </div> <div style="display: none;" id="Dados-Escolares" class="anchor"> <h2>Dados Escolares</h2> Content for "Dados Escolares" Goes Here<br><br><br><br> </div> <div style="display: none;" id="Dados-Tecnicos" class="anchor"> <h2>Dados Tecnicos</h2> Content for "Dados Tecnicos" Goes Here<br><br><br><br> </div> <div style="display: none;" id="Dados-Medicos" class="anchor"> <h2>Dados Medicos</h2> Content for "Dados Medicos" Goes Here<br><br><br><br> </div> </div> <button type="submit" value="Entrar" />Entrar</button> <button type="reset" value="Limpar" name="B2">Limpar</button> </form> <?php } function ValidarFormulario(){ $nome = mysql_real_escape_string($_POST['nome']); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $email = mysql_real_escape_string($_POST['email']); $nivel= mysql_real_escape_string($_POST['nivel']); $estado = mysql_real_escape_string($_POST['estado']); include("BD.php"); $baseDados= new BD(); $baseDados->dbconnect(); $baseDados->registoUser($nome,$username,$password,$email,$nivel,$estado); } ?> <?php if ($_POST['username']) { ValidarFormulario(); MostrarFormulario(); }else MostrarFormulario(); ?> </CENTER> </div> </body> <p> </html>