Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Mencantumkan kode program di posting Anda, tolong ikuti aturan yang sesuai, baca http://diskusiweb.com/discussion/39204/aturan-cara-menyisipkan-kode-program-di-diskusiweb

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

ASK >>>Tolong di bantu tentang database

Mau tanya nie..
gmana sih cara nampilin seluruh isi field database ke combo box,,

mohon pencerahanya
terimakasi

Tanggapan

  • Masa ga bisa?

    Looping databasenya pake foreach atau while,
    Terus tinggal pake SELECT - OPTION
  • edited October 2011
    <div class='geshi_syntax'><table><tr><td><div class='code'><pre class="php"><span class="kw2"><?php</span>
    <span class="kw1">include</span> <span class="st0">"connect.php"</span><span class="sy0">;</span>
     
    <span class="kw1">echo</span> <span class="st0">"<select name='name'>"</span><span class="sy0">;</span>
     
    <span class="re0">$data</span> <span class="sy0">=</span> <span class="kw3">mysql_query</span><span class="br0">(</span><span class="st0">"SELECT field FROM tabel"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="kw1">while</span><span class="br0">(</span><span class="re0">$d</span><span class="sy0">=</span><span class="kw3">mysql_fetch_array</span><span class="br0">(</span><span class="re0">$data</span><span class="br0">)</span><span class="br0">)</span>
    <span class="br0">{</span>
    <span class="kw1">echo</span> <span class="st0">"<option value='<span class="es4">$d[field]</span>' /><span class="es4">$d[field]</span> atau statement</option>"</span><span class="sy0">;</span>
    <span class="br0">}</span>
     
    <span class="kw1">echo</span> <span class="st0">"</select>"</span><span class="sy0">;</span>
    <span class="sy1">?></span></pre></div></td></tr></table></div>
    mas @puetra.. maaf, itu blum saya tes, coz lgi di warnet tmen,hehe. tpi kira" bgitulah.
Sign In or Register to comment.