- data disimpan sementara di localhost lalu buat kode penghubung antara local dan server online, kode ini dinamakan http API, formatnya bisa pakai XML atau JSON,
- model kedua, database langsung disimpan di server hosting dengan cara mengarahkan server databse ke IP address server hosting, cara ini bisa bila pakai hosting vps, bila pakai shared hosting dan pakai cpanel maka tanya dulu apakah bisa akses mysql dari luar, karena secara default di cpanel hanya bisa akses hanya dari localhost sendiri.
Kode PHP
Selasa, 16 September 2014
input dari localhost tapi database tersimpan di server online ?
bagaimana membuat kode php, input di server local tapi data bisa di akses secara online? ada 2 macam cara :
Selasa, 01 Juli 2014
membuat grafik javascript denga dhtmlx
grafik ini bisa diakses dari web pc atau android
<!--conf
<sample>
<product version="2.6" edition="std"/>
<modifications>
<modified date="100609"/>
</modifications>
</sample>
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Labels</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlxchart.css"/>
<script src="../../../codebase/dhtmlxchart.js"></script>
<script >
var dataset_colors = [
{ id:1, sales:210, year:"02", color: "#ee4339"},
{ id:2, sales:55, year:"03", color: "#ee9336"},
];
</script>
</head>
<body >
<div id="chartDiv" style="width:300px;height:250px;margin:2px"></div>
<script>
var chart = new dhtmlXChart({
view:"bar",
container:"chartDiv",
value:"#sales#",
label:"#sales#",
color:"#color#",
radius:3,
width:70,
tooltip:{
template:"#sales#"
},
xAxis:{
title:"Sales per year",
template:"'#year#",
lines: false
},
padding:{
left:5,
right:5,
top:10
}
});
chart.parse(dataset_colors,"json");
</script>
</body>
</html>
<!--conf
<sample>
<product version="2.6" edition="std"/>
<modifications>
<modified date="100609"/>
</modifications>
</sample>
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Labels</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlxchart.css"/>
<script src="../../../codebase/dhtmlxchart.js"></script>
<script >
var dataset_colors = [
{ id:1, sales:210, year:"02", color: "#ee4339"},
{ id:2, sales:55, year:"03", color: "#ee9336"},
];
</script>
</head>
<body >
<div id="chartDiv" style="width:300px;height:250px;margin:2px"></div>
<script>
var chart = new dhtmlXChart({
view:"bar",
container:"chartDiv",
value:"#sales#",
label:"#sales#",
color:"#color#",
radius:3,
width:70,
tooltip:{
template:"#sales#"
},
xAxis:{
title:"Sales per year",
template:"'#year#",
lines: false
},
padding:{
left:5,
right:5,
top:10
}
});
chart.parse(dataset_colors,"json");
</script>
</body>
</html>
Jumat, 23 Mei 2014
membuat kolom komentar facebook
buka ini
https://developers.facebook.com/docs/plugins/comments
tambahkan kode
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/id_ID/sdk.js#xfbml=1&appId=272296136237800&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://pollingsms.com/index.php" data-numposts="20" data-colorscheme="light"></div>
https://developers.facebook.com/docs/plugins/comments
tambahkan kode
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/id_ID/sdk.js#xfbml=1&appId=272296136237800&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://pollingsms.com/index.php" data-numposts="20" data-colorscheme="light"></div>
Rabu, 21 Mei 2014
kode buat grafik garis pakai js.morris
<link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
kode php membuat grafik bar pake morris
<!doctype html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://raw.github.com/DmitryBaranovskiy/raphael/300aa589f5a0ba7fce667cd62c7cdda0bd5ad904/raphael-min.js"></script>
Minggu, 14 Juli 2013
Kode mengambil key dan nilai dari array
ini bakal sering dipakai jadi saya tulis
<?php
$testarr = array("a" => 1, "b" => 2, "c" => 3, "d" => 4);
echo "ap";
print_r($testarr);
echo "<hr>";
$testarr_keys = array_keys($testarr);
$testarr_values = array_values($testarr);
for ($i = 0; $i <count($testarr) ; $i++) {
//testarr[$testarr_keys[$i]] = $testarr_values[$i] * 2;
// echo "testarr_keys $testarr_keys[$i]<br>";
echo "testarr_values $testarr_values[$i]<br>";
}
?>
<?php
$testarr = array("a" => 1, "b" => 2, "c" => 3, "d" => 4);
echo "ap";
print_r($testarr);
echo "<hr>";
$testarr_keys = array_keys($testarr);
$testarr_values = array_values($testarr);
for ($i = 0; $i <count($testarr) ; $i++) {
//testarr[$testarr_keys[$i]] = $testarr_values[$i] * 2;
// echo "testarr_keys $testarr_keys[$i]<br>";
echo "testarr_values $testarr_values[$i]<br>";
}
?>
Rabu, 27 Februari 2013
code php get array from excel file xlsx
<table border=1>
<?php
//<pre>
//error_reporting(E_ALL);
set_time_limit(0);
ini_set("memory_limit","256M");
include 'rand.php';
include 'PHPExcel.inc.php';
include "db.php";
mysql_connect($site["dbhost"], $site["dblogin"], $site["dbpass"]);
mysql_select_db($site["dbname"]);
date_default_timezone_set('Asia/Jakarta');
$inputFileName = $_GET[inputFileName];
$mulai = $_GET[mulai];
echo "inputFileName $inputFileName <br>";
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'include_lib/Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$csheet = $objPHPExcel->getSheetCount();
$loadedSheetNames = $objPHPExcel->getSheetNames();
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
$hal++;
$ahal[] = $hal;
if($hal==1){
}
// echo "hal $hal <br>";
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$cbaris = count($sheetData);
$cbaris1 = $cbaris+1;
for($baris=1;$baris<$cbaris1;$baris++){
$koloma= $sheetData[$baris][A];
$kolomb= $sheetData[$baris][B];
$kolomc= $sheetData[$baris][C];
$kolomd= $sheetData[$baris][D];
$kolome= $sheetData[$baris][E];
$kolomf= $sheetData[$baris][F];
$kolomg= $sheetData[$baris][G];
$kolomh= $sheetData[$baris][H];
$kolomk= $sheetData[$baris][K];
$koloml= $sheetData[$baris][L];
$kolomj= $sheetData[$baris][J];
echo "$koloma - $kolomb - $kolomc - $kolomd - $kolome - $kolomf - $kolomg - $kolomh - $kolomi - $kolomj <br>";
}
}
echo "OK";
?>
Langganan:
Postingan (Atom)