This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function passa ( $val, $w ){ | |
$val["idade"] += $w["idade"];// aqui ele vai pegar o valor do array e irá somar. | |
return $val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function mapear( $dados ){ | |
return $dados['idade']; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = file_get_contents( "http://dados.ufrn.br/api/action/datastore_search?resource_id=ff0a457e-76fa-4aca-ad99-48aebd7db070&limit=1" ); | |
// Aqui vai ser o linnk do json que irão mandar | |
$users = json_decode ( $url, true ); | |
// essa variavel $users irá pegar o json e transforma-la em array | |
$OqueEuQueroDoJson = "nome"; | |
print_r($users["result"]["records"][0][$OqueEuQueroDoJson]); | |
//print_r no caso faz com que ele exiba array.. e assim fica mais facil pra vc pegar alguma informação | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*{ | |
}/* Onde fica o artigo*/ | |
#conteudo>p{ | |
text-align:justify; | |
margin:20px; | |
font-size: 20px; | |
font-family: medium-content-sans-serif-font,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue", sans-serif; | |
color:#333; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $connDB->prepare('SELECT * FROM topic WHERE topic_name LIKE :keywords'); | |
$query->bindValue(':keywords', '%' . $searchQ . '%'); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$pdo = new PDO('mysql:host=localhost;dbname=teste', 'admin', "Sua senha[O ideal é que ela seja uma varipavel]"); | |
$data = "julionsdcs@gmail.com"; | |
/* aqui pode ser usado o $_GET ou qualquer recebimentos NÃO se esqueça de usar o filter_var */ | |
/* o prepare faz o que faria o query, dentro dela é apenas inserir códigos do sql, nesse exemplo usei o mariadb, mas ele pode | |
ser qualquer um outro e o código será o mesmo, se for sql | |
*/ | |
$stmt = $pdo->prepare("INSERT INTO contador (email) VALUES(:email)"); | |
/* Aqui pode mandar os dados no formato de array usando o execute() função nativa, pode usar um json_decode() em caso de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$pdo = new PDO('mysql:host=localhost;dbname=teste', 'admin', "baruch hashem"); | |
$stmt = $pdo->prepare('DELETE FROM contador WHERE email = :id'); | |
$stmt->execute( | |
array( | |
':id' => 'meuemail@gmail.com' | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try{ | |
$mongo = new MongoDB\Driver\Manager(); | |
$query = new mongoDB\Driver\Query([], ['sort' => ['nome' => 1], 'limit' => 5]); | |
$rows = $mongo->executeQuery("teste.clientes", $query); | |
foreach($rows as $row){ | |
echo "$row->nome:$row->profissao\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date('d-m-Y'); | |
$pdo = new PDO('mysql:host=localhost;dbname=meuBancoDeDados', $username, $password); | |
$consulta = $pdo->query("SELECT email, contador, titulos, mensagens data FROM minhaTabela;"); | |
// while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { | |
// echo "Nome: {$linha['nome']} - Usuário: {$linha['usuario']}<br />"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype HTML> | |
<html lang="pt-BR"> | |
<head> | |
<meta charset="utf-8"/> | |
<meta name="viewport" content="width=device-width, user-scalable=no"/> | |
<title>Exemplo | Tratar</title> | |
<link rel="shortcut icon" href="img/icn.png" type="image/x-png"/> | |
<style>/* código css para formatar o nosso pequeno formulário de teste */ | |
body{ | |
height:100%; |