Bir döngüde birden fazla TR yazdırıyyorsanız ve hepsinin ayni fon rengine sahip olmasını istiyorsanız smarty cycle'ı assignile beraber kullanın.
Archive for the 'Php' Kategori
JavaScript ile tablo TR lerini gözter/gizle yapıyorum ama nedense bazen tablo şekli bozuluyor. Bu işin sırrı şurada imiş :
-
function kategori_gizle_goster(i) {
-
if (i == 1) {
-
document.getElementById('kategori_tr').style.display = 'none';
-
}
-
if (i==2) {
-
document.getElementById('kategori_tr').style.display = 'table-row';
-
}
-
}
style.display = 'table-row' şeklinde tekrar gösterirseniz sorun çıkmıyor.
Arama sonuçlarında aranan kelimenin fon rengini javascrip ile değiştirmek istiyorsanız jQuery ve hilight eklentisini kullanabilirsiniz.
jQuery
hilight eklentisi
Örnek Kod :
-
-
.highlight { background-color: yellow }
-
</style>
-
-
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
-
<script type="text/javascript" src="jquery.highlight-2.pack.js"></script>
-
-
</head>
-
<div id="highlight-plugin">
-
Işık Tut <br>
-
bu satırlar ara satırlar
<br> -
Işık Tut <br>
-
bu satırlar ara satırlar
<br> -
Işık Tut <br>
-
bu satırlar ara satırlar
<br> -
</div>
-
-
<a href="javascript:void($('#highlight-plugin').removeHighlight().each(function() { $.highlight(this, 'IŞIK TUT')}))">Işık Tut</a>
-
-
<a href="javascript:void $('#highlight-plugin').removeHighlight();">Normal Yap</a>
-
-
<script type="text/javascript">
-
<!-- eger sayfa acılır açılmaz ışık tutmak istiyorsanız aşağıdaki kodu yazın -->
-
$(document).ready(function(){
-
$('#highlight-plugin').removeHighlight().each(function() { $.highlight(this, 'BU SATIRLAR ARA SATIRLAR :)')})
-
});
-
</script>
-
-
</body>
-
</html>
memcache.inc.php
ekte :
-
<?php
-
/**
-
* versiyon 2.0 <25.11.2008>
-
* Ayhan BARIŞ <info...ayhanbaris.com>
-
* MySQL entegre edilmiş hali
-
* memcache hakkında bilgileri MySQL e yazar
-
* böylece MySQL den select çekerek belirli bir key grubu silinebilir yada bilgileri gösterilebilir
-
* mesela WHERE key LIKE 'user_%' gibi bir sorgu ile gelen değerleri toplu olarak mymemcache_delete e gönderilebilir.
-
* yada o key şu anda memcachede mi diye sorgulanabilir.
-
**/
-
-
/**
-
CREATE TABLE `memcache_status` (
-
`id` int(10) unsigned NOT NULL auto_increment,
-
`key` varchar(255) NOT NULL,
-
`set_time` int(11) unsigned NOT NULL,
-
`expire` int(11) unsigned NOT NULL,
-
`size` int(10) unsigned NOT NULL,
-
PRIMARY KEY (`id`)
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='hafizadaki memcache durumu' AUTO_INCREMENT=1 ;
-
**/
-
-
/**
-
* memcache 'den data alir
-
*
-
* @param string $key
-
* @return string
-
*/
-
function mymemcache_get($key) {
-
global $config;
-
if ( $config["debug"] == 1 ) {
-
return false;
-
}
-
@$memcache = new Memcache;
-
@$memcache->pconnect($config['memcache_host'], $config['memcache_port']);
-
@$template = $memcache->get($key);
-
@$memcache->close();
-
return $template;
-
}
-
}
-
-
/**
-
* memcache 'e data gonderir, set eder
-
* $flag true ise memcache 'e set edilecek datayi zlib ile compress eder.
-
*
-
* @param string $key
-
* @param data $value
-
* @param boolean $flag
-
* @param integer $expire
-
*/
-
function mymemcache_set($key, $value, $flag=false, $expire=900) {
-
$memcache = new Memcache;
-
$memcache->pconnect($config['memcache_host'], $config['memcache_port']);
-
$memcache->set($key, $value, $flag, $expire);
-
$memcache->close();
-
-
# memcache_status e işle
-
$SQL="SELECT id FROM memcache_status WHERE `key`='$key' ";
-
$sorgu = $db->Execute($SQL);
-
if($sorgu->RecordCount() == 0) {
-
$SQL2="INSERT INTO memcache_status SET `key`='$key' , set_time='$set_time' , expire='$expire' , size='$size' ";
-
}
-
else {
-
$SQL2="UPDATE memcache_status SET set_time='$set_time' , expire='$expire' , size='$size' WHERE `key`='$key' ";
-
}
-
$sorgu2 = $db->Execute($SQL2);
-
}
-
}
-
-
/**
-
* memcache'den key i verilen datayi siler.
-
*
-
* @param string $key
-
* @return boolean
-
*/
-
function mymemcache_delete($key) {
-
$memcache = new Memcache;
-
$memcache->pconnect($config['memcache_host'], $config['memcache_port']);
-
$action = $memcache->delete($key);
-
$memcache->close();
-
-
# memcache_status e işle
-
$SQL2="DELETE FROM memcache_status WHERE `key`='$key' LIMIT 1 ";
-
$sorgu2 = $db->Execute($SQL2);
-
-
return $action;
-
}
-
}
-
-
/**
-
* memcache server hakkinda istatistiksel veriler gosterir.
-
*
-
* @return array
-
*/
-
function mymemcache_getStats() {
-
global $config;
-
$memcache = new Memcache;
-
$memcache->pconnect($config['memcache_host'], $config['memcache_port']);
-
$stats = $memcache->getStats();
-
$memcache->close();
-
return $stats;
-
}
-
}
-
-
/**
-
* memcache'deki tum verileri siler.
-
*
-
* @return boolean
-
*/
-
function mymemcache_flush() {
-
$memcache = new Memcache;
-
$memcache->pconnect($config['memcache_host'], $config['memcache_port']);
-
$action = $memcache->flush();
-
$memcache->close();
-
-
# memcache_status e işle
-
$SQL2="TRUNCATE TABLE memcache_status ";
-
$sorgu2 = $db->Execute($SQL2);
-
-
return $action;
-
}
-
}
-
?>
Memcache 'li programlama yapısında genelde şu mantık kullanılır:
-
$kayit = $memcache->get( 'yorum_sayisi' . $resim_id );
-
if( !$kayit ) {
-
$kayit = 0; # db den gelen veri 0 olsun
-
$memcache->set('yorum_sayisi' . $resim_id , $kayit, false, 10);
-
}
Ama siz bu yapıyı kullanmayın !
Bunun yerine :
-
$kayit = $memcache->get( 'yorum_sayisi' . $resim_id );
-
if( $kayit === false ) {
-
$kayit = 0; # db den gelen veri 0 olsun
-
$memcache->set('yorum_sayisi' . $resim_id , $kayit, false, 10);
-
}
kullanın.
Sebebine gelince ; Memcache de sayisal veri tutuyorsanız, ki bu örnekte resmin yorum sayisini db 'den çekip memcache yazdığımızı varsayalim.
İlk yapı hatalı çalışacaktır. Çünkü yorum sayısı 0 olan bir resim için !$kayit ifadesi herzaman true olur ve memcache istediğimiz gibi çalışmaz.
memcached şu anda arka planda çalışıyor mu kontrol etmek için :
Bilgisayarımı açtım, ufak ufak kod yazmaya da başladım. Bugün farkettim ki Edit Plus 'ı 999 gündür kullanıyormuşum
işte resmi aşağıda...

Xajax birçok fonksiyon register etmek yerine sadece bir tane EmirKULU'nuz olsun. Siz yapılaca işi ve işlenecek veriyi EmirKULU'nuza verin gerisini o halletsin.
<?php
define("DEFAULT_CHARSET" , 'iso-8859-9');
require_once("xajax_core/xajax.inc.php");
$xajax = new xajax();
$xajax->setCharEncoding(DEFAULT_CHARSET);
function emirKulu($is,$veri) {
global $objResponse,$newContent;
$newContent="";
$objResponse = new xajaxResponse(DEFAULT_CHARSET);
switch($is) {
case 'sari': sari($veri);
break;
case 'yesil': yesil($veri);
break;
default : isYok($veri);
}
return $objResponse;
}
function sari($veri) {
foreach($veri as $n => $v){$$n = $v;}
global $objResponse,$newContent;
$newContent="sari = $sayi";
$objResponse->assign("yer","innerHTML",$newContent);
}
function yesil($veri) {
foreach($veri as $n => $v){$$n = $v;}
global $objResponse,$newContent;
$newContent="yesil = $sayi";
$objResponse->assign("yer","innerHTML",$newContent);
}
$xajax->registerFunction("emirKulu");
$xajax->processRequest();
?>
<html>
<head>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="history" content="">
<meta name="author" content="Verdana Core, phpdoc.net Inc.">
<title></title>
<?php $xajax->printJavascript(); ?>
</head>
<body>
<div id="yer">burası degisecek</div>
<form method=post action="" id="form1">
<input type="text" name="sayi" value="5">
</form>
<input type="button" onclick="xajax_emirKulu('sari',xajax.getFormValues('form1'));" value="Sari">
<input type="button" onclick="xajax_emirKulu('yesil',xajax.getFormValues('form1'));" value="Yeşil">
</body>
</html>
Yüksek performanslı, dağıtık, nesne tabanlı önbellekleme yazılımıdır. Linux serverda bir servis olarak çalışır. PHP,C,PERL vb. programlama dilleri API ile Memcached 'e erişerek veri depolatabilirler.
Genellikle dinamik web uygulamalarını hızlandırmak amacı ile kullanılır.
SQL sorgu sonucunu veya Php 'nin oluşturduğu Html sayfayı memcached 'de depolayabilirsiniz.
Böylece web sitesi ram'den çalışırmışcasına hızlı açılır, aynı Sql sorgularını ve Php komutlarını tekrar tekrar çalıştırmaz, ön bellekten okuyarak ziyaretçiye/istemciye sunar.
Web sitelerinde kullanım yerleri olarak ;
- Sık ziyaret edilen sayfalar. Detay Sayfaları, Ana Sayfa, Arama Sonuç...
- Session bilgilerinin tutulması.
- Sık kullanılan ve veritabanından gelen veriler/diziler/objeler.
(more...)

Entries (RSS)