19 Şubat 2013 Salı

How to set default current date time in mysql's column?

ALTER TABLE `sample` ADD COLUMN `current_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP

10 Şubat 2013 Pazar

Php ile hava durumu çekme

Php ile hava durumu çekme

     Bir proje için hava durumunu göstermem gerekiyordu. Google da biraz dolaştıktan sonra bulduğum kod ve scriptler çok uzundu ve/veya sayfayı çok kasıyordu. Ben de ünlü deyimimizde olduğu gibi kendi göbeğimi kendim kesmeye karar verdim.
  • Bunun için php explode fonksiyonunu kullanmak en pratik yol (xml işlemleri ile uğraşmamak için)
  • Hava durumunu alabileceğimiz güvenilir bir kaynak ( yahoo weather )
  • Ve biraz da kod;
<?php
$site="http://weather.yahooapis.com/forecastrss?w=29391294&u=c";
$ssite=  file_get_contents($site);
$site1=  explode('</pubDate>', $ssite);
$site1= explode('temp="', $site1[1]);
$site1= explode('"', $site1[1]);
echo $site1[0],"&deg;<br> <img src='",$site1[4],"'>";
?>


Ekran Görüntüsü

 10°
        Tabii ki değişkenleri istediğiniz şekilde süsleyerek sayfanıza yerleştirebilirsiniz.

30 Ocak 2013 Çarşamba

How to dynamically change a web page's title?


You can change the title via three ways:


1- (does not work in IE) put <title id='ttl'>Hello</title> in html, thendocument.getElementById('ttl').innerHTML = 'World' in javascript.
2- (similar to 1) put <title>Hello</title> in html, and thendocument.getElementsByTagName('title')[0].innerHTML = 'world'
3- (works everywhere) document.title = 'World'
1 and 2 are slightly obscure and unstandard ways to change the title, and is probably not reccomended, so I would go with the third, seeing as it works in every browser