Jump to content


k9studio's Content

There have been 4 items by k9studio (Search limited from 17/04/2023)


Ordernar por                Order  

#1019851 Foreach + While

Posted by k9studio on 06/01/2013, 21:30 in PHP

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...



#1019550 Script Que Mostra Apenas O Ano Atual (2012)

Posted by k9studio on 09/10/2012, 11:14 in Javascript / DOM / AJAX / ECMAScript

Olá

mostrando só o ano:

<script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
document.write(""+year+"")
</script>



#1017217 Função Não Chama No Chrome

Posted by k9studio on 28/02/2012, 09:07 in Javascript / DOM / AJAX / ECMAScript

Olá Feko,

fiz como indicou mais continua a mesma coisa, no chrome não funciona, versão do chrome 19.0.1054.0 canary

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();
}
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)
}



#1017213 Função Não Chama No Chrome

Posted by k9studio on 28/02/2012, 07:51 in Javascript / DOM / AJAX / ECMAScript

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>




IPB Skin By Virteq