Skip to content

Instantly share code, notes, and snippets.

View kodetop's full-sized avatar

Kodetop kodetop

View GitHub Profile
@kodetop
kodetop / user-profile.php
Last active August 16, 2020 18:18
Code Style: Ejemplo sin PSR-1
<?php
class user_profile
{
const version = '1.0';
var $name = 'Guest';
function GetName()
{
return $this->name;
@kodetop
kodetop / countries.php
Created March 31, 2020 04:11
PDO: Connection
<?php
// include connection
require 'pdo.php';
@kodetop
kodetop / countries.php
Created March 31, 2020 02:55
PDO: Countries
<ul>
<?php while (($result = $statement->fetch()) !== false): ?>
<li><a href="country.php?code=<?php echo $result->code; ?>"><?php echo $result->name; ?></a></li>
<?php endwhile; ?>
</ul>
@kodetop
kodetop / countries.php
Created March 31, 2020 02:53
PDO: Countries
<?php
// include connection
require 'pdo.php';
// prepare query
$statement = $pdo->prepare("SELECT * FROM country");
$statement->execute();
@kodetop
kodetop / country.php
Created March 31, 2020 02:51
PDO: Country
<h1>Country</h1>
<p>
<strong>Name</strong>: <?php echo $result->name; ?><br>
<strong>Continent</strong>: <?php echo $result->continent; ?><br>
<strong>Region</strong>: <?php echo $result->region; ?><br>
<strong>Population</strong>: <?php echo number_format($result->population); ?><br>
<strong>Area</strong>: <?php echo number_format($result->area); ?><br>
<strong>Head of State</strong>: <?php echo $result->headofstate; ?>
</p>
<p>
@kodetop
kodetop / country.php
Last active March 31, 2020 03:12
PDO: Country detail
<?php
// include connection
require 'pdo.php';
// get and filter parameter
$code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
// prepare query
$statement = $pdo->prepare("SELECT * FROM country WHERE Code = :code");
$statement->bindValue(':code', $code, PDO::PARAM_STR);
@kodetop
kodetop / pdo-query.php
Created March 31, 2020 02:13
PDO: Query data
<?php
// include connection
require 'pdo.php';
// send query
$statement = $pdo->prepare("SELECT * FROM country");
$statement->execute();
// loop and print data
while (($result = $statement->fetch()) !== false) {
@kodetop
kodetop / .editorconfig
Created March 29, 2020 18:46
EditorConfig: basic
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@kodetop
kodetop / .editorconfig
Last active March 29, 2020 18:47
EditorConfig: advanced
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@kodetop
kodetop / index.html
Created March 29, 2020 03:05
ES6: module use
<script src="main.js" type="module"></script>