Skip to content

Instantly share code, notes, and snippets.

View KimiyukiYamauchi's full-sized avatar

Kimiyuki Yamauchi KimiyukiYamauchi

View GitHub Profile
@KimiyukiYamauchi
KimiyukiYamauchi / bmi.php
Last active December 28, 2015 04:58
BMI値を計算する
<?php
function bmi ($height,$mass)
{
$height = $height / 100;
$mass = $mass / ($height * $height);
return $mass;
}
function h($str) {
return htmlspecialchars($str, ENT_QUOTES, "UTF-8");
@KimiyukiYamauchi
KimiyukiYamauchi / DataAccess.java
Last active December 28, 2015 04:59
javaからOracleに接続
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DataAccess {
public static void main(String[] args) {
DataAccess dataAccess =new DataAccess();
<?php
require 'MDB2.php';
//$db = MDB2::connect('mysql://s11011:password@localhost/db11');
$db = MDB2::connect('oci8://s11011:[email protected]:1521/?service=db11');
if (MDB2::isError($db)) { die("connection error: " . $db->getMessage()); }
$q = $db->query("CREATE TABLE dishes (
dish_id INT,
dish_name VARCHAR(255),
price DECIMAL(4,2),
is_spicy INT
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// Load PEAR MDB2
<?php
//print a text box
function input_text($element_name, $values) {
print '<input type="text" name="' . $element_name .'" value="';
print h($values[$element_name]) . '">';
}
//print a submit button
function input_submit($element_name, $label) {
print '<input type="submit" name="' . $element_name .'" value="';
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
/* Create Table for 実習 */
DROP TABLE IF EXISTS ord_details;
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS employees;
DROP TABLE IF EXISTS departments;
DROP TABLE IF EXISTS salgrades;
DROP TABLE IF EXISTS products;
<?php
// Load PEAR MDB2
require 'MDB2.php';
// Load the form helper functions
require 'formhelpers.php';
// Connect to the database
require 'connect_mysql.php';
$db = connect_mysql();
// Set up automatic error handling
<?php
function connect_mysql(){
$db = MDB2::connect('mysql://test:pass@localhost/testphp');
if (MDB2::isError($db)) { die("connection error: " . $db->getMessage()); }
return $db;
}
?>
<?php
// Load PEAR MDB2
require 'MDB2.php';
// Load the form helper functions.
require 'formhelpers.php';
require 'connect_mysql.php';
// Connect to the database