Jump to content


marcos223

Member Since 24/01/2016
Offline Last Active 14/09/2017, 23:37
-----

Topics I've Started

exibir valores repetidos e quantas vezes foi repetido

16/08/2017, 11:17

Meu algoritimo precisa exibir os valores de um vetor quantas vezes os valores idgitados deste valor foram repetidos, mas o problema é que eu não consigo agrupar os valores repetidos para serem exibidos somente um vez e ao lado a quantidade de vezes que ele foi repetido, como no exemplo,

EX: NUMERO 1 REPETE 2 VEZ(ES)

      NUMERO 3 REPETE 1 VEZ(ES)

      NUMERO 12 REPETE 4 VEZ(ES)

 

se puderem me ajudar agradeço a ajuda.

 

 

#include<stdio.h>
#include<conio.c>
#include <locale.h> //necessário para usar setlocale

int main(void){
    setlocale(LC_ALL,"portuguese");
    
    int k[12], cont, num = 0, soma;
    
    for(cont=0;cont<12;cont++){
        printf("Digite %iº valor = ",cont);
        scanf("%i",&k[cont]);
    }
    for(cont=0;cont<12;cont++){
        for(num=0;num<12;num++){
            if(k[cont] == k[num]){
                soma++;
            }
        }
        
            if(soma >= 1){
                printf("%i | %i\n", k[cont],soma);
                soma = 0;
            }
            
        
    }
}

 

 


Internal Server Error

16/11/2016, 22:17

estou desenvolvendo um site com urls amigaveis, estava tudo normal, mas derrepente no servidor apareceu esta msg

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@main-hosting.eu to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

 

enteri em contato com meu servidor e eles me dissram q o problema esta no meu script, mas não consigo achar o erro.

OBS: localhost funciona tudo perfeito, só no servidor é que não funciona

 

já tentei tudo e não consigo achar o problema.

 

 

.htaccess

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
Options -Indexes
 

 

config.php

<?php
//host
define('HOST', 'host');
//usuario
define('USER', 'root');
//senha
define('PASS', '');
// base de dados
define('BD', 'banco');
//url
define('PATH', 'http://www.videirasapucaia.esy.es');
?>

 

index.php

 

<?php include "includes/header.php";?>
    <main class="container-fluid" id="conteudo"><!-- div conteudo -->
      <?php

    $url = (isset($_GET['url'])) ? htmlentities(strip_tags($_GET['url'])) : "";
        
            $parametros    = explode('/', $url);
                 $paginas_permitidas = array('home','igreja','celula','escola','encontro','culto','videos','pregacao','quebra-gelo',
                 'galeria','agenda','videira-news','contato','evento','palavra');
                             
            if(isset($_GET['s']) && $_GET['s'] != ""){
                include_once "pages/busca.php";
                }else{
                    if($url == ''){
                        include_once "pages/home.php";
                }elseif(in_array($parametros[0], $paginas_permitidas)){
                    include_once "pages/".$parametros[0].'.php';
                    
                }elseif($parametros[0] == 'categoria'){
                    if(isset($parametros[1]) && !isset($parametros[2])){
                        include_once "pages/categoria.php";
                        }elseif(isset($parametros[2])){
                            include_once "pages/subcategoria.php";    
                        }
                    }else{
                    include_once "pages/erro404.php";    
                }
            }
            
?>
    </main>
    <!-- fim div conteudo -->
    <?php include  "includes/footer.php";?>

 

 

 


calendario de eventos

01/11/2016, 23:16

adequei um codigo e não consigo buscar os dados do banco de dados, sempre retorna o primeiro id do banco não importa quantos registros tenha no banco

 

 <?php
$pdo = new PDO('mysql:host=localhost;dbname=agenda','root','');
$pdo ->exec("set names utf8");

    function num($num){
        return ($num < 10) ? '0'.$num : $num;
    }

    function montaEventos($info){
        global $pdo;
        //tabela, data, titulo
        $tabela = $info['tabela'];
        $data = $info['data'];
        $titulo = $info['titulo'];
        $link = $info['link'];
        $id = $info['id'];

        $eventos = $pdo->prepare("SELECT * FROM `".$tabela."` WHERE `".$data."` >= NOW()");
        $eventos->execute();

        $retorno = array();
        while($row = $eventos->fetchObject()){
            $dataArr = date('Y-m-d', strtotime($row->{$data}));
            $retorno[$dataArr] = array(
                'titulo' => $row->{$titulo},
                'id' => $row->{$id}
            );
        }
        return $retorno;
    }


    function diasMeses(){
        $retorno = array();

        for($i = 1; $i<=12;$i++){
            $retorno[$i] = cal_days_in_month(CAL_GREGORIAN, $i, date('Y'));
        }

        return $retorno;
    }

    function montaAgenda($eventos = array()){
        $daysWeek = array(
            'Sun',
            'Mon',
            'Tue',
            'Wed',
            'Thu',
            'Fri',
            'Sat'
        );
        $diasSemana = array(
            'Dom',
            'Seg',
            'Ter',
            'Qua',
            'Qui',
            'Sex',
            'Sab'
        );

        $arrayMes = array(
            1 => 'Janeiro',
            2 => 'Fevereiro',
            3 => 'Março',
            4 => 'Abril',
            5 => 'Maio',
            6 => 'Junho',
            7 => 'Julho',
            8 => 'Agosto',
            9 => 'Setembro',
            10 => 'Outubro',
            11 => 'Novembro',
            12 => 'Dezembro'
        );

        $diasMeses = diasMeses();
        $arrayRetorno = array();

        for($i =1; $i <= 12; $i++){
            $arrayRetorno[$i] = array();
            for($n=1; $n<= $diasMeses[$i]; $n++){
                $dayMonth = gregoriantojd($i, $n, date('Y'));
                $weekMonth = substr(jddayofweek($dayMonth, 1),0,3);
                if($weekMonth == 'Mun') $weekMonth = 'Mon';
                $arrayRetorno[$i][$n] = $weekMonth;
            }
        }

        echo '<a href="#" id="volta">&laquo;</a><a href="#" id="vai">&raquo;</a>';
        echo '<table class="table table-responsive">';
        foreach($arrayMes as $num => $mes){
            echo '<tbody id="mes_'.$num.'" class="mes">';
            echo '<tr class="mes_title"><td id="mes" colspan="7">'.$mes.'</td></tr>';
            echo '<tr class="dias_title">';
            foreach($diasSemana as $i => $day){
                echo '<td>'.$day.'</td>';
            }
            echo '</tr><tr>';
            $y = 0;
            foreach($arrayRetorno[$num] as $numero => $dia){
                $y++;
                if($numero == 1){
                    $qtd = array_search($dia, $daysWeek);
                    for($i=1; $i<=$qtd; $i++){
                        echo '<td></td>';
                        $y+=1;
                    }
                }
                if(count($eventos) > 0){
                    $month = num($num);
                    $dayNow = num($numero);
                    $date = date('Y').'-'.$month.'-'.$dayNow;
                    if(in_array($date, array_keys($eventos))){
                        $evento = $eventos[$date];
                        
                        echo '<td class="evento"><a href="#"  title="'.$evento['titulo'].'">
<button type="button" class="evento" data-toggle="modal" data-target="#myModal" style="background:none;border:none;">'.$numero.'</button></a>';?>
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close fechar" data-dismiss="modal">&times;</button>
        <?php
        $id = $evento['id'];
        $selecionarDados = @BD::conn()->prepare("SELECT * FROM tbl_agenda WHERE id =  ?");
        @$selecionarDados->execute(array($id));
        $ex = $selecionarDados -> fetchObject();
        ?>
        <h4 class="modal-title"><?php echo @$ex->titulo;?></h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
        <?php var_dump($id);?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn botao" data-dismiss="modal">Fechar</button>
      </div>
    </div>
  </div>
</div><?php
echo'</td>'
                    }else{
                        echo '<td id="dias_mes" class="dia_'.$numero.'">'.$numero.'</td>';
                    }
                }else{
                    echo '<td id="dias_mes" class="dia_'.$numero.'">'.$numero.'</td>';
                }
                if($y == 7){
                    $y=0;
                    echo '</tr><tr>';
                }
            }
            echo '</tr></tbody>';
        }
        echo '</table>';
    }
    
?>


IPB Skin By Virteq