alexa-tracking

nanya tentang php dan mysql

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/558a1aa360e24b18478b4568/nanya-tentang-php-dan-mysql
nanya tentang php dan mysql
gan, yang jago php
newbie mau nanya neh...

saya ingin select database dan memasukannya dalam form input,

jadi scriptnya kira2 begini
Code:

<?php
include "koneksi.php";


$select1 = "select count(no_rekening) as jml FROM tabung WHERE tgl_registrasi >='2015-01-21'";
$select_query1 = mysql_query($select1);
while($select_result = mysql_fetch_array($select_query1))
{
$jml = $select_result['jml'] ;
}

$select = "SELECT no_rekening FROM tabung WHERE tgl_registrasi >='2015-01-21'";
$select_query = mysql_query($select);
while($select_result = mysql_fetch_array($select_query))
{
$no_rekening = $select_result['no_rekening'] ;
for ($i=1; $i<=$jml ; $i++)
{
echo " <input type='text' name='no_rekening".$i."' value='$no_rekening'><br/>";
}
}

?>


tapi setelah dieksekusi, hasilnya seperti ini gan
Code:

<input type='text' name='no_rekening1' value='10.005555'><br/>
<input type='text' name='no_rekening2' value='10.005555'><br/>
<input type='text' name='no_rekening3' value='10.005555'><br/>
<input type='text' name='no_rekening4' value='10.005555'><br/>
<input type='text' name='no_rekening1' value='10.005556'><br/>
<input type='text' name='no_rekening2' value='10.005556'><br/>
<input type='text' name='no_rekening3' value='10.005556'><br/>
<input type='text' name='no_rekening4' value='10.005556'><br/>
<input type='text' name='no_rekening1' value='10.005557'><br/>
<input type='text' name='no_rekening2' value='10.005557'><br/>
<input type='text' name='no_rekening3' value='10.005557'><br/>
<input type='text' name='no_rekening4' value='10.005557'><br/>
<input type='text' name='no_rekening1' value='10.005558'><br/>
<input type='text' name='no_rekening2' value='10.005558'><br/>
<input type='text' name='no_rekening3' value='10.005558'><br/>
<input type='text' name='no_rekening4' value='10.005558'><br/>


gimana caranya kalau hasilnya seperti yg diinginkan, yaitu
Code:
<input type='text' name='no_rekening1' value='10.005555'><br/> 
<input type='text' name='no_rekening2' value='10.005556'><br/>
<input type='text' name='no_rekening3' value='10.005557'><br/>
<input type='text' name='no_rekening4' value='10.005558'><br/>


Quote:


Coba pake ini gan :
Code:

<?php

include "koneksi.php";

$i = 1;
$select = "SELECT no_rekening FROM tabung WHERE tgl_registrasi >='2015-01-21'";
$select_query = mysql_query($select);
while($select_result = mysql_fetch_array($select_query)){
$no_rekening = $select_result['no_rekening'] ;
echo " <input type='text' name='no_rekening".$i."' value='$no_rekening'><br/>";
$i++;
}
?>
Quote:


hasilnya gini gan
Code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\simultan\cek3.php on line 15


baris 15 itu yg ini
Code:

while($select_result = mysql_fetch_array($select_query)){


update
works gan ... ane yang salah, belum ganti koneksinya emoticon-Cape d... (S)

makasih gaaan emoticon-Blue Guy Peace
KASKUS Ads
Quote:


coba di share tabel tabung nya gan, kemungkinan ada kesalahan penulias field atau nama tabelnya.
Quote:


udh bisa, gan.. makasih banyak emoticon-I Love Indonesia (S)
ane yang salah belum ganti koneksinya emoticon-Hammer (S) emoticon-Hammer (S)