stripeskid Posted August 2, 2012 at 04:20 PM Report Share #471307 Posted August 2, 2012 at 04:20 PM (edited) Boa tarde, Eu tenho aqui uma duvida, tenho duas tabelas diferentes e duas querys diferentes que se aplicam a essas tabelas. Tabela1 id:1 id:2 id:3 Tabela2 id:1 id:3 As querys1 e query2 resultam isso mesmo, 1,2,3 e 1,3 respectivamente. Agora existe uma checkbox que precisa de ser alterada para "checked" se algum valor da tabela2 pertencer a tabela1. Pensei em algo como isto: <?php while($row = mysql_fetch_array($Query1)) { while($row2 = mysql_fetch_array($Query2)) { $checkit = ''; if($row['id'] == $row2['id'] ) $checkit = 'checked="yes"'; } ?> <input type="checkbox" name = "checkbox-1" class="checkbox" value ="" <?php echo $checkit ?> /> <?php } } ?> Mas não funciona, ou melhor funciona apenas para o primeiro resultado encontrado e depois salta fora :S Alguem me pode ajudar? Edited August 2, 2012 at 04:21 PM by stripeskid Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 2, 2012 at 04:38 PM Report Share #471308 Posted August 2, 2012 at 04:38 PM o que faz saltar o código é que não estás a fazer o rewind do apontador interno do recordset $Query2 no fim do ciclo externo mas fora do ciclo interno executa if (mysql_data_seek($Query2, 0) === false) die("Recordset unable to be rewinded"); IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
stripeskid Posted August 2, 2012 at 05:40 PM Author Report Share #471313 Posted August 2, 2012 at 05:40 PM (edited) Obrigado pela resposta, entretanto consegui resolver por outra abordagem. Edited August 2, 2012 at 05:42 PM by stripeskid Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 2, 2012 at 05:49 PM Report Share #471314 Posted August 2, 2012 at 05:49 PM Obrigado pela resposta, entretanto consegui resolver por outra abordagem. ainda bem .. porque sinceramente o que parece que pretendes fazer tem um aspecto muito estranho ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now