i have an mysql column explode method
here is the code :
$barang2=mysql_query("select * from tbl_barang WHERE INDX=2");
while($c=mysql_fetch_array($barang2)) {
$result = "$c[DESKRIPSI]<br />";
$rows = explode("#", $result);
for($i = 0; $i < count($rows); $i++) {
$temp = explode(':', $rows[$i]);
$IDK = $temp[1];
$ID = array("ID Kategori : ","Kategori : ","Warna : ","Ukuran : ","B : ");
//echo '<br />' . $ID . ' : ';
echo $ID[0]. ' : '. $IDK[0] . '<br />';
echo $ID[1]. ' : '. $IDK[1] . '<br />';
echo $ID[2]. ' : '. $IDK[2] . '<br />';
echo $ID[3]. ' : '. $IDK[3] . '<br />';
echo $ID[4]. ' : '. $IDK[4] . '<br />';
}
}
i get the column on mysql where its like IDK:16#K:BAJU#W:HITAM#U:L#B:120G
then trying to get it like
ID Kategori : 16
Kategori : BAJU
Warna : HITAM
Ukuran : L
B : 120G
but i cant call the offset like $IDK[0]
and join the first array...
mysql_
functions as they have been deprecated. Switch tomysqli_
orPDO
. (going with the theme).$result
does not have rows in it, it is a single array. There is no need for a for loop here. – Jay Blanchard Jul 8 at 13:19echo $ID . ' : '. $IDK . '<br />';
but the$ID
doesnt comes up with my every single array... – user3816415 Jul 8 at 13:30