Selasa, 01 Mei 2012 - 20:20:20 WIB
Teknik Looping Didalam Looping Disertai Studi Kasusnya
Diposting oleh : Wiro Sableng
Kategori: Umum - Dibaca: 399505 kali

Dalam logika pemrograman, looping (perulangan) digunakan untuk mengulang suatu proses. Namun, dalam tutorial kali ini, saya tidak akan membahas dasar-dasar looping (perulangan), jadi saya langsung aja ke permasalahannya mengapa diperlukan looping didalam looping? Dalam kasus tertentu, looping saja tidaklah cukup, misalnya membuat rekap data yang kompleks dari beberapa tabel dan menampilkan masing-masing berita dalam suatu kategori. Dalam kedua kasus tersebut diperlukan looping didalam looping (while didalam while).

Agar tidak tambah bingung, saya akan berikan contohnya secara bertahap, biasanya dalam menampilkan data dalam suatu tabel kategori hanya diperlukan satu looping, contoh skripnya sebagai berikut:

 

Apabila dijalankan di browser, maka hasilnya dapat dilihat pada gambar berikut:

Selanjutnya, kita akan menampilkan beberapa berita didalam masing-masing kategori. Logikanya, setelah looping (while) untuk menampilkan kategori, maka perlu diselipkan satu looping lagi untuk menampilkan berita didalam looping kategori. Dan tentu saja, berita yang tampil haruslah berhubungan dengan kategorinya.

Untuk itu, coba perhatikan dulu relasi antara tabel kategori dengan tabel berita pada gambar berikut:

Kemudian baru kita bikin skripnya sebagai berikut:

 

Sekarang coba jalankan di browser, maka hasilnya dapat dilihat pada gambar berikut:

Saya juga telah mengimplementasikan teknik looping didalam looping di CMS Lokomedia pada templates eL jQuery ala Yahoo, silahkan buka file kiri.php pada folder templates/eljquery-yahoo. Hasilnya dapat dilihat pada gambar berikut:

Oke, demikianlah sekilas kegunaan teknik looping dalam looping. Untuk mendownload skrip dan database latihannya, silahkan Klik Disini.




    17405 Komentar :

    Chloe
    18 Februari 2016 - 19:22:28 WIB

    I know this web site provides quality dependent posts
    and other stuff, is there any other web page which provides these
    stuff in quality?
    Elite Diet Cleanse is it safe
    18 Februari 2016 - 20:27:26 WIB

    This is a topic which is close to my heart... Take care!
    Exactly where are your contact details though?
    search Engine optimisation Strategy
    19 Februari 2016 - 02:09:02 WIB

    Wow, marvelous weblog structure! How long have you been running a blog for?
    you made blogging glance easy. The whole look of your site is excellent, as
    neatly as the content material!
    Ram
    19 Februari 2016 - 08:46:54 WIB

    Nice post. I was checking continuously this blog and I am impressed!
    Extremely helpful information specifically the last
    part :) I care for such info a lot. I was looking for this particular information for a very long
    time. Thank you and best of luck.
    Garcinia Cambogia Xtra weight loss supplement
    20 Februari 2016 - 05:49:13 WIB

    Have you ever considered about adding a little bit more than just
    your articles? I mean, what you say is fundamental and all.

    Nevertheless think about if you added some great photos or video
    clips to give your posts more, "pop"! Your content is excellent but with pics and video clips, this blog could definitely be one of the very best in its niche.
    Very good blog!
    Nature's Answer Astragalus Ingredients
    20 Februari 2016 - 13:24:49 WIB

    Way cool! Some very valid points! I appreciate you penning
    this post and also the rest of the website is very good.
    Mattress covers for bed Bugs
    21 Februari 2016 - 00:34:00 WIB

    Attractive section of content. I just stumbled upon your web site and in accession capital to
    assert that I acquire actually enjoyed account your blog posts.

    Any way I will be subscribing to your augment and even I achievement you access consistently rapidly.
    bed bug mattress cover
    21 Februari 2016 - 06:12:59 WIB

    You are so awesome! I do not think I have read anything like this before.
    So wonderful to find somebody with unique thoughts on this subject.
    Really.. many thanks for starting this up. This site is one thing that is required on the internet, someone with a bit of originality!
    mattress covers for bed bugs
    21 Februari 2016 - 07:58:16 WIB

    Undeniably believe that which you said. Your favorite reason appeared to be on the internet the easiest thing to be
    aware of. I say to you, I definitely get irked while people consider worries that
    they plainly do not know about. You managed to hit the nail
    upon the top as well as defined out the whole thing without
    having side effect , people can take a signal. Will likely be back to get more.
    Thanks
    mattress covers for bed bugs
    21 Februari 2016 - 10:02:22 WIB

    Thanks for the good writeup. It in fact used to be a enjoyment
    account it. Glance complicated to far introduced agreeable from you!
    By the way, how can we be in contact?
    << First | < Prev | 1 | 2 | 3 | ... | 1741 | Next > | Last >>
    Isi Komentar :
    Nama :
    Website :
    Komentar
     365220
     (Masukkan 6 kode diatas)