catfox @ ウィキ
新しいページ
最終更新:
catfox
-
view
php側では、JavaScriptで埋め込むので以下の事を書かなければならない?
<?
header( "Content-Type: text/javascript; Charset=euc-jp" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
?>
document.write(出力データ)
DB設定
テーブル名:cntlog
テーブル名:cntlog
| 列名 | 型 |
| acnt | int |
conf.php:DB接続用の設定
db.php:DBの接続等のクラス
db.php:DBの接続等のクラス
ac.php
<?
require_once("conf.php");
require_once("db.php");
header( "Content-Type: text/javascript; Charset=euc-jp" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
$SQL = new DB();
$Query = "update cntlog set acnt = acnt + 1";
$SQL->QuerySe($Query);
$Query = "select acnt from cntlog";
$Column = $SQL->QueryEx($Query);
$SQL->Close();
?>
document.write("<SPAN style='color:black'><?= $Column['acnt'] ?></SPAN><br>");
my_build.htm
出力結果を画像として出力するので、header();を以下のようする
header("Content-type: image/png");
pic.php
<?
require_once("conf.php");
require_once("db.php");
# **********************************************************
# このソースコードは、utf-8s で記述されています
# ( ソースそのものの形式は utf-8n です )
# **********************************************************
header("Content-type: image/png");
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
$SQL = new DB();
$Query = "update cntlog set acnt = acnt + 1";
$SQL->QuerySe($Query);
$Query = "select acnt from cntlog";
$Column = $SQL->QueryEx($Query);
$SQL->Close();
$img_text = $Column['acnt'];
$font_path = "C:\WINDOWS\Fonts\MSGOTHIC.TTC";
# **********************************************************
# 内部コードは、EUC-JP
# **********************************************************
mb_language( "ja" );
mb_internal_encoding( "UTF-8" );
# **********************************************************
# キャンバス作成
# **********************************************************
$im = imagecreate( 150, 30 );
# ***********************************************************
# 画像の背景色
# imagecolorallocate() の最初のコールで背景色がセットされます
# ***********************************************************
$white = imagecolorallocate( $im, 255, 255, 255 );
# ***********************************************************
# 画像の文字色
# ***********************************************************
$black = imagecolorallocate( $im, 0, 0, 255 );
imagettftext(
$im,
20, # サイズ
0, # 角度
5, # x 座標
22, # y 座標
$black,
$font_path,
$img_text);
# ***********************************************************
# PNG 出力
# ***********************************************************
imagepng($im);
# ***********************************************************
# 終了処理
# ***********************************************************
imagecolordeallocate( $im, $black );
imagecolordeallocate( $im, $white );
imagedestroy($im);
?>
my_build.htm
<IMG
src="pic.php"
border="0"
galleryimg="no" />