Olá Meus Amigos,
Estou aqui quebrando a cabeça...
Bem, estou tentando fazer o seguinte.
tenho uma tabela que guarda autorização de cada usuário
o id separado por virgula
1,2,3
depois eu chamo com foreach
assim:
$num = explode(",", $row->autorizados);
foreach($num as $i){
}
agora que vem o problema tenho a listagem com while
o id que tiver autorizado ficar ticado no checkbox, e quando desmarcar o checkbox e atualizar ficar desmarcado no checkbox
o que não estou conseguindo colocar o foreach dentro do while quando faço isso a listagem duplica, alguém pode ajudar?
como posso colocar os ids do foreache dentro do while sem duplicar os registros?
$sqln = mysql_query("SELECT * FROM TblUniverso where id_usuario = '".$id_usu."'");
$totalRegistros = mysql_num_rows($sqln);
while($res = mysql_fetch_object($sqln)){ ?>
<input type="checkbox" value="<?php echo $res->id?>" name="bloco[<?php echo $res->id?>]" <?php if(1 == 1){?>checked="checked"<?php } ?>/><?php echo $res->nome;?><br>
<?php
}
?>
Pessoal espero que tenha explicado direito...
- Fórum WMO
- → Viewing Profile: Tópicos: k9studio
Community Stats
- Group Usuários
- Active Posts 291
- Profile Views 2142
- Member Title k9studio
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Male
-
Interesses
php, mysql, asp
Contact Information
- Windows Live netwebx@hotmail.com
1
Neutral
User Tools
Friends
k9studio hasn't added any friends yet.
Latest Visitors
Topics I've Started
Foreach + While
06/01/2013, 21:30
Função Não Chama No Chrome
28/02/2012, 07:51
Meus amigos,
Estou com esse código a baixo, no explorer e mozila funciona muito bem mais no chrome não funciona.
a função é chamada por um select
alguem aqui pode ajudar a encontrar uma solução?
function objetoAjax(){
var xmlhttp=false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",file,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
catch(e)
{
xmlhttp = false;
}
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function List(id){
divCategorias = document.getElementById('categorias');
ajax=objetoAjax();
ajax.open("GET", "list.php?pag="+id);
divCategorias.innerHTML= '<img src="images/loading.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divCategorias.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
<select class="sty_select" id="cat" name="cat"/>
<option onClick="List('id=1');">id 1</option>
<option onClick="List('id=2');">id 2</option>
</select>
Estou com esse código a baixo, no explorer e mozila funciona muito bem mais no chrome não funciona.
a função é chamada por um select
alguem aqui pode ajudar a encontrar uma solução?
function objetoAjax(){
var xmlhttp=false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
try //Google Chrome
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",file,false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
catch(e)
{
xmlhttp = false;
}
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function List(id){
divCategorias = document.getElementById('categorias');
ajax=objetoAjax();
ajax.open("GET", "list.php?pag="+id);
divCategorias.innerHTML= '<img src="images/loading.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divCategorias.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
<select class="sty_select" id="cat" name="cat"/>
<option onClick="List('id=1');">id 1</option>
<option onClick="List('id=2');">id 2</option>
</select>
- Fórum WMO
- → Viewing Profile: Tópicos: k9studio
- Privacy Policy
- Regras ·