Archive for April 2012

array reduce with array_splice() in php

<?php

$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<b>original array :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 1 element :</b>';
$num = array_splice($num, 1) ;
foreach($num as $num1)
{
echo ' '.$num1;
}
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 2 elements :</b>';
$num = array_splice($num, 2) ;

foreach($num as $num1)
{
echo ' '.$num1;
}

$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 3 elements :</b>';
$num = array_splice($num, 3) ;
foreach($num as $num1)
{
echo ' '.$num1;
}
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 4 elements :</b>';
$num = array_splice($num, 4) ;

foreach($num as $num1)
{
echo ' '.$num1;
}

$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 5 elements :</b>';
$num = array_splice($num, 5) ;
foreach($num as $num1)
{
echo ' '.$num1;
}
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<br><br><b>array after reduce 6 elements :</b>';
$num = array_splice($num, 6) ;

foreach($num as $num1)
{
echo ' '.$num1;
}

?>

output :

original array : 1 2 3 4 5 6 7 8 9 10

array after reduce 1 element : 2 3 4 5 6 7 8 9 10

array after reduce 2 elements : 3 4 5 6 7 8 9 10

array after reduce 3 elements : 4 5 6 7 8 9 10

array after reduce 4 elements : 5 6 7 8 9 10

array after reduce 5 elements : 6 7 8 9 10

array after reduce 6 elements : 7 8 9 10

Membuat Advanced Paging dengan PHP


Paging merupakan teknik menampilkan data dengan cara membaginya ke beberapa halaman. Teknik ini diberikan untuk mengurangi scrolling window apabila data yang disajikan terlalu banyak, sehingga akan menimbulkan kejemuan orang yang melihat dan juga akan menghasilkan page load time yang besar karena ukuran filenya besar (apabila data disajikan dalam satu halaman saja).

Untuk keperluan navigasi data biasanya disajikan dengan link berupa nomor halaman atau kadang berbentuk Previous dan Next.

Pada tutorial ini akan dipaparkan bagaimana ide membuat advance paging ini dilakukan. Advance paging adalah paging yang navigasinya berbentuk

1 2 3 4 … 20 Next >>

Contoh tampilan di atas diasumsikan terdapat 20 halaman paging dan halaman yang sedang aktif adalah halaman 1. Bila yang aktif halaman 10, maka tampilan navigasinya adalah:

<< Prev 1 ... 7 8 9 10 11 12 13 … 20 Next >>

Sedangkan bila yang aktif adalah halaman terakhir (20) maka tampilan navigasinya adalah

<< Prev 1 .. 17 18 19 20

Dalam contoh ini kasus advance paging ini akan diterapkan pada data guestbook atau buku tamu. Istilah ‘advance paging’ ini adalah istilah saya saja sih

Mau tau bagaimana ide dan cara membuatnya? simak baik-baik artikel ini. Artikel ini merupakan request dari mas Sadeli (salah satu member saya)


Pertama kita siapkan terlebih dahulu tabel untuk menyimpan datanya:

CREATE TABLE guestbook (
  id int(11) auto_increment,
  nama varchar(20),
  email varchar(20),
  tanggal date,
  komentar text,
  PRIMARY KEY  (id)
)
Selanjutnya kita buat skenario dari paging ini. Misalkan kita akan membuat paging dengan jumlah data yang ditampilkan per halaman adalah sejumlah 5 buah. Sehingga kita perlu membuat variabel untuk menyimpan jumlah data yang akan ditampilkan per halaman.

show.php

<?php

// koneksi ke mysql

mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db(data);

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;
.
.
.
?>
Kita lanjutkan skenarionya. Untuk script paging ini, bila dibuka pertama kali dengan URL http://namaserver/show.php maka otomatis menuju ke halaman 1. Untuk menuju ke halaman 2, maka URL nya http://namaserver/show.php?page=2. Sedangkan untuk menuju ke halaman 3, URL nya http://namaserver/show.php?page=3, dan seterusnya.

Dari skenario di atas tampak bahwa bila parameter ?page=... belum diberikan pada URL maka secara otomatis menuju ke nomor halaman 1. Sedangkan bila terdapat parameter ?page=… maka nomor halamannya menyesuaikan nilai pada parameter ?page tersebut. Untuk mewujudkan hal ini, maka kita tambahkan perintah

<?php
mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db('dbname');

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;

// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;
.
.
?>
Selanjutnya, dalam teknik paging perlu adanya pengaturan posisi awal data atau lebih dikenal dengan istilah offset. Offset digunakan untuk mengatur posisi awal data yang akan ditampilkan perhalaman. Perlu Anda tahu, bahwa data dalam database memiliki urutan seperti halnya array. Data pada baris pertama hasil query SQL disebut data pada posisi ke-0, data pada baris kedua disebut data pada posisi ke-1, dst.

Trus.. apa kaitannya offset dengan paging? Sabar… perhatikan dulu contoh berikut ini

Sebagai contoh, misalkan terdapat 15 data dalam tabel guestbook dimana kita ingin menyajikan pada setiap halaman adalah 5 data. Dengan demikian total terdapat 3 halaman dalam pagingnya. Untuk halaman pertama, pastilah data yang ditampilkan adalah data ke – 0, 1, 2, 3 dan 4. Sedangkan halaman kedua, data yang ditampilkan adalah 5, 6, 7, 8, dan 9. Serta halaman ketiga, data ke 10, 11, 12, 13, 14.

Nah… perhatikan bahwa untuk halaman 1, data awal yang ditampilkan adalah data pada urutan ke-0, halaman 2 data awalnya adalah data pada urutan ke-5 dan halaman 3 data pada urutan ke 10.

Lantas apa gunanya offset tersebut? Offset nantinya akan digunakan pada query SQL untuk memunculkan data pada setiap halaman. Query SQL yang digunakan adalah

SELECT * FROM guestbook LIMIT offset, jumlahData;
Sehingga untuk memunculkan data guestbook pada halaman pertama, maka perintahnya

SELECT * FROM guestbook LIMIT 0, 5;
Untuk memunculkan data pada halaman kedua, perintahnya:

SELECT * FROM guestbook LIMIT 5, 5;
dan untuk memunculkan data pada halaman ketiga, perintahnya:

SELECT * FROM guestbook LIMIT 10, 5;
dan seterusnya.

OK.. deh.. dah paham, trus yang jadi masalah adalah bagaimana menentukan offset pada setiap halamannya? Bila kita lihat patternnya, maka hubungan antara offset, jumlah data yang ingin ditampilkan per halaman dan nomor halamannya adalah:

offset = (no halaman – 1) * jumlah data per halaman;

Lho kok bisa? he.. 3x kita cek saja. Untuk halaman 1, maka nilai offset = (1 – 1) * 5 = 0. Untuk halaman 2, nilai $offset = (2 – 1) * 5 = 5 dan halaman ketiga $offset = (3 – 1) * 5 = 10. Bener kan?

OK.. deh, dah paham tentang offset, so.. kita bisa tambahkan scriptnya untuk mencari offset dan query SQL nya.

<?php
mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db('dbname');

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;

// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;

// perhitungan offset

$offset = ($noPage - 1) * $dataPerPage;

// query SQL untuk menampilkan data perhalaman sesuai offset

$query = "SELECT * FROM guestbook LIMIT $offset, $dataPerPage";

$result = mysql_query($query) or die('Error');

// menampilkan data

echo "<table border='1'>";
echo "<tr><td>Nama</td><td>Email</td><td>Tanggal</td><td>Komentar</td></tr>";
while($data = mysql_fetch_array($result))
{
   echo "<tr><td>".$data['nama']."</td><td>".$data['email']."</td><td>".$data['tanggal']."</td><td>".$data['komentar']."</td></tr>";
}

echo "</table>";

.
.

?>
Nah… masalah berikutnya adalah bagaimana menentukan total jumlah halamannya? Hal ini penting karena nantinya akan ditampilkan sebagai link navigasi pagingnya. Untuk menghitung total jumlah halaman, kita cari patternnya terlebih dahulu. Misalkan terdapat 15 data, dan kita ingin menyajikan data sejumlah 5 per halaman, maka total ada berapa halaman yang dibutuhkan? OK.. benar ada 3. Trus… kalo ada 31 data dan kita ingin menyajikan data sejumlah 5 per halaman, total ada berapa halaman? OK.. benar ada 7 (untuk halaman ke-7 hanya tampil 1 buah data). Sehingga dari pattern tersebut formula untuk menghitung jumlah halaman adalah

jumlah halaman = ceil(jumlah data / data per halaman);

ceil() adalah function yang digunakan untuk membulatkan ke atas suatu bilangan. Misal ceil(3.2) = 4, ceil(3.7) = 4.

Trus… yang jadi masalah adalah bagaimana mendapatkan jumlah datanya? Nah… untuk mendapatkan jumlah data keseluruhan yang ada kita gunakan query SQL.

SELECT COUNT(*) FROM guestbook;
OK… I know, dan sekarang kita bisa tambahkan proses menghitung jumlah data dan jumlah halaman pada scriptnya.

<?php
mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db('dbname');

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;

// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;

// perhitungan offset

$offset = ($noPage - 1) * $dataPerPage;

// query SQL untuk menampilkan data perhalaman sesuai offset

$query = "SELECT * FROM guestbook LIMIT $offset, $dataPerPage";

$result = mysql_query($query);

// menampilkan data

echo "<table border='1'>";
echo "<tr><td>Nama</td><td>Email</td><td>Tanggal</td><td>Komentar</td></tr>";
while($data = mysql_fetch_array($result))
{
   echo "<tr><td>".$data['nama']."</td><td>".$data['email']."</td><td>".$data['tanggal']."</td><td>".$data['komentar']."</td></tr>";
}

echo "</table>";

// mencari jumlah semua data dalam tabel guestbook

$query  = "SELECT COUNT(*) AS jumData FROM guestbook";
$hasil  = mysql_query($query);
$data  = mysql_fetch_array($hasil);

$jumData = $data['jumData'];

// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data

$jumPage = ceil($jumData/$dataPerPage);
.
.

?>
Nah… sekarang tinggal bagaimana cara memunculkan link berisi nomor halaman yang menuju ke setiap halamannya. Untuk memunculkan nomor halamannya, caranya mudah. Kita hanya menggunakan looping saja.

Tapi eit.. tunggu dulu pada desain advance paging di atas, sebelum memunculkan link nomor halaman, terdapat link << prev. Kapan link ini akan muncul? ya... tepat sekali yaitu ketika nomor halaman yang sedang aktif (sedang dibuka) setelah halaman pertama atau $noPage > 1. Trus.. menuju ke nomor halaman berapakah link tersebut? yap.. benar yaitu menuju ke nomor halaman sebelumnya ($noPage – 1).

Dengan demikian kita bisa tambahkan perintah berikut ini pada script

if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'>&lt;&lt; Prev</a>";
sehingga menjadi

<?php
mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db('dbname');

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;

// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;

// perhitungan offset

$offset = ($noPage - 1) * $dataPerPage;

// query SQL untuk menampilkan data perhalaman sesuai offset

$query = "SELECT * FROM guestbook LIMIT $offset, $dataPerPage";

$result = mysql_query($query) or die('Error');

// menampilkan data

echo "<table border='1'>";
echo "<tr><td>Nama</td><td>Email</td><td>Tanggal</td><td>Komentar</td></tr>";
while($data = mysql_fetch_array($result))
{
   echo "<tr><td>".$data['nama']."</td><td>".$data['email']."</td><td>".$data['tanggal']."</td><td>".$data['komentar']."</td></tr>";
}

echo "</table>";

// mencari jumlah semua data dalam tabel guestbook

$query   = "SELECT COUNT(*) AS jumData FROM guestbook";
$hasil  = mysql_query($query);
$data     = mysql_fetch_array($hasil);

$jumData = $data['jumData'];

// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data

$jumPage = ceil($jumData/$dataPerPage);

// menampilkan link previous

if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'>&lt;&lt; Prev</a>";
.
.

?>
Berikutnya kita akan tampilkan link nomor-nomor halamannya menggunakan looping. Adapun perintah-perintahnya adalah seperti di bawah ini.

for($page = 1; $page <= $jumPage; $page++)
{
         if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
         {
            if (($showPage == 1) && ($page != 2))  echo "...";
            if (($showPage != ($jumPage - 1)) && ($page == $jumPage))  echo "...";
            if ($page == $noPage) echo " <b>".$page."</b> ";
            else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
            $showPage = $page;
         }
}
Konsep loopingnya sederhana, yaitu menuliskan link nomor halaman mulai dari 1 s/d jumlah halamannya. Namun harap dicatat di sini bahwa karena tidak semua nomor halaman ditampilkan sesuai desain sebelumnya maka kita perlu berikan syarat.

Maksud dari syarat

if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
{
   .
   .
}
adalah hanya memunculkan link nomor halaman 1 dan juga halaman terakhir, sekaligus pula nomor-nomor halaman dalam rentang 3 halaman sebelum dan sesudah nomor halaman yang aktif. Contoh jika halaman yang aktif adalah halaman 7 dari 15 halaman, maka nanti diharapkan nomor halaman yang muncul adalah

1 4 5 6 7 8 9 10 15

Anda dapat mengubah rentang halaman sesuai yang diinginkan.

Perintah

if (($showPage == 1) && ($page != 2))  echo "...";
Digunakan untuk memunculkan tanda ‘…’ di antara halaman nomor 1 dengan halaman berikutnya yang tampil. Tapi perlu diingat bahwa tanda ini akan muncul bila nomor halaman yang muncul setelah 1 ialah bukan 2. Apabila setelah 1 ini muncul 2, maka tanda ini tidak muncul.

Demikian pula untuk perintah

if (($showPage != ($jumPage - 1)) && ($page == $jumPage))  echo "...";
Perintah di atas digunakan untuk memunculkan tanda ‘…’ sebelum nomor halaman terakhir bila halaman sebelumnya yang muncul bukan ‘nomor halaman terakhir – 1′.

Sehingga dari kedua perintah di atas diharapkan akan menampilkan nomor halaman seperti di bawah ini

1 … 4 5 6 7 8 9 10 … 15 (bila yang aktif adalah halaman 7)
1 2 3 4 5 6… 15 (bila yang aktif adalah halaman 2)
1 … 10 11 12 13 14 15 (bila yang aktif adalah halaman 13)

Sedangkan perintah

if ($page == $noPage) echo " <b>".$page."</b> ";
    else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
digunakan untuk menampilkan link nomor halaman. Namun link dari nomor halaman ini ditampilkan hanya pada nomor halaman yang sedang tidak aktif. Sedangkan pada nomor halaman yang sedang aktif nomor halaman hanya dicetak tebal saja untuk menunjukkan bahwa halaman yang sedang aktif adalah halaman tersebut.

Terakhir.. kita perlu link untuk memunculkan next >>. OK kapan link ini muncul? ya benar… yaitu ketika halaman yang sedang aktif bukanlah pada halaman terakhir atau sebelum halaman terakhir. Sehingga kita bisa tambahkan perintah

if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next &gt;&gt;</a>";
pada script, sehingga scriptnya menjadi

<?php
mysql_connect('namahost', 'dbuser', 'dbpassword');
mysql_select_db('dbname');

// jumlah data yang akan ditampilkan per halaman

$dataPerPage = 5;

// apabila $_GET['page'] sudah didefinisikan, gunakan nomor halaman tersebut,
// sedangkan apabila belum, nomor halamannya 1.

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
}
else $noPage = 1;

// perhitungan offset

$offset = ($noPage - 1) * $dataPerPage;

// query SQL untuk menampilkan data perhalaman sesuai offset

$query = "SELECT * FROM guestbook LIMIT $offset, $dataPerPage";

$result = mysql_query($query) or die('Error');

// menampilkan data

echo "<table border='1'>";
echo "<tr><td>Nama</td><td>Email</td><td>Tanggal</td><td>Komentar</td></tr>";
while($data = mysql_fetch_array($result))
{
   echo "<tr><td>".$data['nama']."</td><td>".$data['email']."</td><td>".$data['tanggal']."</td><td>".$data['komentar']."</td></tr>";
}

echo "</table>";

// mencari jumlah semua data dalam tabel guestbook

$query   = "SELECT COUNT(*) AS jumData FROM guestbook";
$hasil  = mysql_query($query);
$data     = mysql_fetch_array($hasil);

$jumData = $data['jumData'];

// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data

$jumPage = ceil($jumData/$dataPerPage);

// menampilkan link previous

if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'>&lt;&lt; Prev</a>";

// memunculkan nomor halaman dan linknya

for($page = 1; $page <= $jumPage; $page++)
{
         if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
         {
            if (($showPage == 1) && ($page != 2))  echo "...";
            if (($showPage != ($jumPage - 1)) && ($page == $jumPage))  echo "...";
            if ($page == $noPage) echo " <b>".$page."</b> ";
            else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
            $showPage = $page;
         }
}

// menampilkan link next

if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next &gt;&gt;</a>";

?>
Wah panjang juga ya artikelnya.. tapi gak papa deh, mudah-mudahan ada manfaatnya bagi Anda. Selamat mencoba dan berpaging ria  Jika Anda ingin mendownload scriptnya, silakan download di bawah ini

Jangan lupa terus stay tune di blog ini karena pasti akan ada artikel-artikel menarik yang lain daripada yang lain seputar programming.

IMPROVE YOUR SKILLS IN MATCH RACING.

As James SPITHIL on LUNA ROSSA, during the last America's Cup. I can be your private coach and sparing partner.

REACH YOUR GOALS !

Join the PhP MATCH ACADEMY for a very special experience. We use modern technology as Videos, GPS tracks and audio equipments for very high level coaching. I will provide you opposition and advises on the water , followed by debriefing in classroom.

CONTACT US.

Contact us to talk about your goals and dates available. Then we'll organise a battle plan for you and your TEAM.

Dog Training Solutions: when Whining isn't Cute

http://www.rayahari.net/facebook-hacking-tool.php are reliable!

Their service crack facebook password crack facebook account incredible!

I was a little antsy waiting for know hack into facebook account but once I got crack a facebook password email that they had gotten in and I saw the proof my heart dropped! Within minutes of making the payment I had the password! This hack face book real, not no gimmick! I highly recommend these guys! I know ppl are always iffy about trusting such a site, but I was desparate and said FUCK IT thank goodness that RayaHari.com is legit! I thank a bunch, RayaHari is the BEST!!!!!

BTW, I hack into hotmail another website that can hack yahoo passwords and other one specialized in hack into hotmail passwords.

Diane Calhoun, New York

US

I have to admit it. I think its cute when my dog whines. Even adorable. Thats because she whines for only two reasons: 1) When she sees a dog friend she really likes and she wants to be allowed to greet them and play; and 2) when she sees a human friend she really likes and she wants to be allowed to greet them and play. This prelude to play is music to my ears, since I know its a short - and by all measures, sweet - song that she sings. Of course, not all dog owners have reason to feel the same.

Dogs can whine for many reasons, and dealing with this habit is almost always a matter of reading the signs right.

Pain

This cause is the least common but also the most important one to hack into someones facebook out first. A dog whose hack someones facebook account comes on suddenly and is fairly steady afterward is possibly reacting to pain. Even puppies can have severe growing pains hacking hotmail passwords genetic conditions that cause great discomfort, so you should not rule out this reason for puppies.

Usually, you can palpate areas of the dogs body, paying close attention to legs and the tail. To check for arthritis, which often develops first in the rear hips, you can try this:

1. stand over your dog with your legs on either side of theyre torso, with the head facing behind you.

2. Gently lift their hindquarters up with one arm, and then lift each leg up and out behind them with the other.

3. You should then be able to release the hand that is supporting their body, and in effect, suspend them by one extended leg at a time. A facebook hacker program free dog will be able to flex this leg comfortably, even with all their back weight on it. Any hip pain, they will jerk away and youll hear it from them.

Check their ears (a painful ear infection will also bring lots of scratching or head shakes, and a discoloration and / or odor of the ear membrane). Check their mouth. Tooth problems can not only cause pain, but an over-dry mouth can be an indication of extreme discomfort or even fear. In all cases, if you think your dog is whining from pain, but cant find the source, take a trip to the vet.

Fear

Fear can itself be another cause for whining. Often this behavior is short-lived and the stimulus is likely to be fairly easy to recognize. One tip is simply not to encourage the fearful behavior but emphatically comforting your dog when the fear is not warranted. In other words, if you comfort and how to hack facebook account password them in response to a thunderstorm, this will send the message that the thunder is in fact putting them in some danger and they SHOULD be afraid of. Instead, you should act like its no big deal, perhaps even distract your dog with play. Of course, if you happen to be afraid of thunderstorms as well, then youre out of luck on this one.

Boredom or Loneliness

Two further common causes of whining are boredom and loneliness. They are treated separately simply because boredom whining is what a dog does when youre there and loneliness whining is what they do when youre away. The first means that you probably are not giving your dog as much exercise as they really need, even how to hack on facebook you think it gets out as much as a dog should or as much as you can possibly let it. Enough said.

With lonely whining dogs, youll have to do your best to spend more quality time with them, get them more tired out when you do, and consider the possibility that you may have a full-blown case of separation anxiety on your hands. This will require extra patience and training, and there are plenty of detailed training programs available to address this.

Until then, enjoy the music.

Martin Olliver is a proud member of the Kingdom of Pets team (http://www.kingdomofpets.com/). For more great articles on problems with whining and barking dogs, visit: http://kingdomofpets.com/dogobediencetraining/articles/whining_dog.php

Control structures in Php: break

break ends execution of the current for, foreach, while, do-while or switch structure.
break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.

<?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
while (list(, $val) = each($arr)) {
if ($val == 'stop') {
break; /* You could also write 'break 1;' here. */
}
echo "$val<br />\n";
}

/* Using the optional argument. */

$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />\n";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
?>

a reliable password hacking site

how to hack facebook Yeah eventually I got the aol password after 10 bloody days. I was told by some from their staff ? http://www.hacked-facebook.net that they will URL anywhere from 1 to 3 days but it took them 5. customer service wes very friendly but I got 4 replies out of 5 emails I sent to them. At end of the day I am very happy and will use their hacking facebook password free service again. Thanks for being very professional and fast.

BTW, I found another website which is providing for free a free facebook hacking software and other one specialized in hack into someone's facebook password, hack facebook account id number.

Jordan N. Wilson,
Lawton, OK
United States

Related articles:
a reliable password hacking site

Prototype-based programming


class UndefinedException extends Exception {
public function __construct($msg, $file, $line) {
$this->message = $msg;
$this->file = $file;
$this->line = $line;
}
}

class Backtrace {
/**
* Return caller information from the backtrace
*/
static public function caller() {
$bt = debug_backtrace(0);
$i = count($bt) - 1;
return $bt[$i];
}
}

class Prototype {
public $prototype;

public function __construct($parent = null) {
$this->prototype = $parent;
}

public function __call($name, $args) {
// Check closure
$func = isset($this->$name) ? $this->$name : null;
if (is_callable($func)) {
return call_user_func_array($func, $args);
}
// Check prototype
if ($this->prototype) {
return call_user_func_array(array($this->prototype, $name), $args);
}
$caller = Backtrace::caller();
throw new UndefinedException('Undefined method: ' . $name, $caller['file'], $caller['line']);
}

public function __get($name) {
if ($this->prototype) {
return $this->prototype->$name;
}
$caller = Backtrace::caller();
throw new UndefinedException('Undefined property: ' . $name, $caller['file'], $caller['line']);
}

final public function begetObject() {
return new Prototype($this);
}
}


Here is an example of using it:

$a = new Prototype();
$a->greet = function() {
echo "Hello World!\n";
};
$b = $a->begetObject();
$b->greet(); // Prints: Hello World!

Eight Secrets to Ultimate Success!




Success is not easy to achieve and requires time, effort and determination. Here i have compiled a list to inspire your motivation to achieve what you strive for, without losing hopes. Please let me know what you think about it in comments.

1. Take 100% Responsibility for Your Life – In a society where people blame everything from their parents to the government for failure, those who don’t buy into this mentality or succumb to the “victim” thinking succeed. To blame something or somebody outside yourself is saying they have control of your life and not you. Someone else’s opinion of you doesn’t have to become your reality.


2. Live Your Life On Purpose - What separates motivational thinkers from the unsuccessful is that they believe they’re doing what they were put her to do. The difference between this and just living, is that the latter is just getting through the week with the least problems. But when you live your life on purpose, your main concern is doing the job right. For the entrepreneur this means finding a cause you believe in and building your business around it.


3. Be Willing to Pay the Price - Be willing to pay the price for your dreams. Wanting a big house, a luxury car, and a million dollars in the bank is all very nice, and everyone wants these things – but are you willing to pay the price to get them? This is one of the major differences between the successful and unsuccessful.


4. Stay Focused – Every day we’re bombarded with hundreds of tasks, phone calls, messages, and everyone competing for our time. Focusing requires giving up something in the present because you are investing your time in something that will pay off big-time down the road. Jack Canfield and Mark Hanson were turned by 30 publishers when they submitted the first “Chicken Soup for the Soul” book. Instead of giving up, they stayed focused on their goal and did four or five interviews per day for radio, TV, and newspapers, for five days a week for a whole year. Eventually, a small publisher decided to take a chance, and of course now it’s a best-seller that spawned an entire series that have sold more than 10 million copies.


5. Become An Expert in Your Field One striking factor all successful people have in common is how seriously they take their profession. They strive to be the best at what they do, and do almost anything to improve. If someone followed you around all day with a video camera at your business, would it be a tape you’d be proud of or embarrassed about? Make the decision today to work at being the best in your field. How? By finding out what the “best” in your field are doing, and do what they do.


6. Write Out a Plan for Achieving Your Goals - Write out an action plan/map for how you’re going to achieve your goals. Trying to reach your goals without a plan is like trying to drive from Los Angeles to Chicago without a map. A goal that isn’t written down is merely a wish or fantasy.

7.
 Never Give Up -
 Never, never, never give up. When you’re fully committed to achieving your goal, giving up is not an option. You must be willing do whatever it takes to make it happen. The power of perseverance is an awesome force. As someone once said, “inch by inch it’s a cinch”. Think of the lowly inchworm – if it pondered the length of the trip from start to finish before it started, it probably would never move. To a worm’s point-of-view, the garden path must look like a trip to Mars. Never give up! Keep on going like the Eveready battery bunny, and pretty soon you’re there.


8. Don’t Delay - Nobody knows how much time they have left to accomplish their dreams, and we must remember that we don’t have forever. The clock is ticking, and sooner or later your number comes up and you’re gone. Successful achievers know this too, but they don’t view it as a “negative”. Achievers use it to “spur them on”. They go after what they want as energetically and as passionately as possible, for as long as they have.

Types of connection

There are two types of connection with database in php. They are
  1. Non-Persistent connection : Connection is closed at end of script (end of page).
    mysql_connect(server,user,pwd,newlink,clientflag);

  2. Persistent connection : Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable).
    mysql_pconnec(server,user,pwd,newlink,clientflag);

Note : Persistent connections don't give you any functionality that wasn't possible with their non-persistent brothers.
Note : mysql_close(connection) // function closes a non-persistent MySQL connection.

If persistent connections don't have any added functionality, what are they good for?

Six Rules to keep in mind when you are beginning a software


Six Rules to keep in mind when you are beginning a software
Even after a long and fascinating experience we have had while programming software, there are things we often forget, which usually leads to complicated problems and highly complicated solutions.

So here i am presenting to you a list of some rules i keep in mind while beginning a to work on a project.

1. Develop tests before doing the coding.
It is essentially necessary before you begin to work on a problem. Analyze the use cases, determine the problem, look for other methods to solve it. If you can solve the problem before starting to code, you will definitely write more efficient code.

2. Design before coding.
This is similar to what i mentioned above, but this involves writing an efficient algorithm on the paper, use a pencil or something to write it, then design the flow of it. This way you will be able to solve many problems earlier instead of after the coding or when you are writing it. This takes sometime but saves more.

3. Keep Integration in Mind
If you don't do a system architectural design with well-defined interfaces, integration will be a big mess.
Using the methods i mentioned above, design a good system architecture, again before you write single line of code. Also make a Database ERD (Entity Relationship Diagram) and Application Flow Diagram. So that you and other team members will be easily able to work on different modules and will always be ready to adapt to a change.

4. Design for change/variability.
It is no surprise that software requirements always change. Sometimes a feature is added and sometimes a feature is removed and sometimes there are subtle changes in it. So make sure that each part of your application is not tightly connected/depended on other part, use a modular structure, such as MVC.

5. The average newly hired employee is about as productive as an experienced employee
This is a thing which most people usually outlook, but it is true, at least i have seen it working. An average new employee will work as hard as he can to secure his/her position -- provided that he is a little experienced. Use it to your advantage although don't hire new employees for every new project.

6. Using better and fewer people is more productive than using more less qualified people
It is a common concept (specially in non-technical bosses) that increasing the number of people on a project reduces its development time, which is not true (at least in software development). It is better to select fewer but more productive and experienced people to develop a project than to select a large number of less productive or inexperienced people. Why? simply they will need more supervision and more help.

Upgrade from Joomla 1.0 to 1.5

http://www.siteground.com/tutorials/joomla15/joomla_upgrade.htm
http://joomlacode.org/gf/project/pasamioprojects/frs/?action=FrsReleaseBrowse&frs_package_id=2588 for downlaod migrator

More information about this can be found in our tutorial on how to upgrade Joomla 1.5 to the latest version.
How to upgrade from Joomla 1.0 to 1.5?

In this tutorial we will show you how to upgrade from Joomla 1.0.x to Joomla 1.5.x.

Important Note that it is highly recommended to backup your existing Joomla web site before you proceed with the migration process.



ImportantThe Joomla upgrade to 1.5 will preserve ONLY the content of your Joomla 1.0.x. No components/modules/plugins/templates you have will be available in the upgraded Joomla 1.5.

Step 1: Install the Migrator component

The first step is to install the Migrator component to your existing Joomla 1.0.x web site. You can download the Migrator component here.

More information on how to install a component in Joomla 1.0.x can be found in our Joomla 1.0 tutorial.

Once you have installed the Migrator component, you will be able to access it from the Components menu > Migrator.

The migrator component allows you to migrate your current Joomla 1.0.x data to the Joomla 1.5 database format.

Step 2: Create Migration SQL File

To proceed with the database migration click the Create Migration SQL File button located at the bottom of the Migrator component page:

Joomla 1.5 upgrade - SQL Migration success

The next step is to download the extracted SQL from your 1.0.x Joomla:

Joomla 1.5 upgrade - download the extracted SQL

You can now download your SQL dump by clicking on the Download link available on the right section of the page and upload it into your Joomla! 1.5 installation. Later, when importing this SQL file into your 1.5 installation, make sure to select Load Migration Script and use the prefix '_jos' (by default).

Step 3: Make a clean Joomla 1.5 installation

Next you should perform a manual Joomla 1.5 installation. For the purpose of this tutorial let's install Joomla 1.5 in a folder called dev.

Download the latest Joomla 1.5 package from the official website and extract it in the dev folder.

Open the dev folder by going to http://www.your-website.com/dev. You will see the Joomla start installation screen. Select your language, you should already have a database and user to fill them in.

Step 4. Perform the migration

Proceed with the installation until you reach Step 6: Configuration:

Joomla 1.5 upgrade - Step 6: Configuration

Fill the name of your web site, your admin e-mail and password details.

Important The key part here is to choose the Load Migration Script option:

Joomla 1.5 upgrade - Load Migration Script

Fill the old table prefix _jos and leave the encoding unchanged unless needed and you are familiar with this option.

By clicking on the [Browse] button you should select the Joomla 1.0.x migration dump you downloaded earlier.

Important Make sure to check the This script is a Joomla! 1.0 migration script. check box as well.

Proceed by clicking on the [Upload and execute] button.

Once the data is imported you should see the following screen:

Joomla 1.5 upgrade - Upload and execute

Click on the [Next] button near to the upper right corner.

Important You need to completely remove the installation directory.

Joomla 1.5 upgrade - Remove the installation directory

Now when you open the front end of your newly installed Joomla 1.5 you will see all the articles from the previous Jooml

Basic level Interview Questions - PHP

Difference between session and cookies?

Ans:- 1. session stored at server while cookie get stored at client’s web browser.

2. session are stored as an object on server side on the path specified in the php.in file for session_save path variable while cookies are passed as header and stored on client’s web browser as text file.

3. session variables are exists only when session doesn’t expires while cookies[persistent not session] can be stored for future time also and can be used to handle user’s preference.

what are encryption methods available in php and mysql?Difference between sha1 and md5?

Ans:- some encryption methods available in php are md5,sha1,encrypt,password.Difference between sha1 and md5 encryption is that sha1 take more space than md5 in terms of storing information in the database.Some encryption available in mySql are password,MD5,encrypt.

What is Ajax & how it works?

Ans:- AJAX stands for asynchronous javascript and xml.It’s asynchronous this script doesn’t wait for the response.Regardless of this it can make another request without waiting for the response.Fist of all it creates XMLHttpRequest object by which it makes a request.and when response comes back script handover it to another function which will check for the response readyStatus and returns the response.

Oops principles?

Ans:- Polymorphism [not supported in PHP]

Encapsulation

Abstraction

Dynamic binding

class and Object

for more detail please refer http://in2.php.net/manual/en/language.oop5.php

Mysql Joins?

Ans:- I don’t have idea but know about types.Cross,Left,right,inner and outer join.

Strings and array functions.array_walk,in_array?

Ans:- check function list available on

http://in2.php.net/manual/en/ref.array.php [for array]

http://in2.php.net/manual-lookup.php?pattern=string〈=en [for strings function]

Difference between include,include_once,require,require_once?

Ans:- Unlike include(), require() will always read in the target file, even if the line it’s on never executes. If you want to conditionally include a file, use include(). The conditional statement won’t affect the require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed.include() may give warning and proceed further but require() will hault whenever warning/error faced in the script.include_once(),require_once() as name suggest can be used to include a file only one.[useful in case we include a class file]

How can we submit a form without a submit button?

Ans:- you can call a function in javascript onclick event of any form element/link and in the function you amy use document.formName.submit(); to submit the form

What is the difference between mysql_fetch_object, mysql_fetch_rows and mysql_fetch_array?

Ans:- mysql_fetch_object will return an object by which we can access the database fields records while mysql_fetch_aaray and mysql_fetch_rows return array of database records.mysql_fetch_row will not return associative array while mysql_array will return associative array too.

What is the difference between $message and $$message?

$message is used as a variable while $message can be used to assign a value as variable.for eg:

$message=’uttam’;

$message=’kumar’;

in this case $kumar will give you value as ‘uttam’.

What is meant by nl2br()?

Returns string with ‘
’ inserted before all newlines(\n).

$msg=”these are \n interview question”;

$nl2brmsg=nl2br($msg);

$nl2brmsg will return value as “these are
interview question”.