php - Print query in while loop, print some fields once, print some field many times -
i wonder how should if wanna print $sta , $stb once, print $test aslong find them in database, $sta , $stb unique key, there many $test in every sta , stb
<?php //establish connection database $host = "*****"; $conn = *******; $query = " select * p100f left outer join ***** test **** p100sta = 1 , p100stb = 1 //execute query $queryexe = db2_exec($conn, $query) ; //fetch results while(db2_fetch_row($queryexe)) { $sta = db2_result($queryexe, 'p100sta'); $stb = db2_result($queryexe, 'p100stb'); $test = ****test****** print("<div class='text-center'> <h2>$sta , $stb</h2> <---------- 1 want print once $test <------------------- 1 want repeat aslong find them in database </div>");
now when have both in while loop printing this.
$sta $stb $test $sta $stb $test $sta $stb $test $sta $stb $test
but want print this
$sta $stb $test $test $test $test $test
any suggetions? in advance
try code //execute query $queryexe = db2_exec($conn, $query) ; //fetch results $i=0; while(db2_fetch_row($queryexe)) { $sta = db2_result($queryexe, 'p100sta'); $stb = db2_result($queryexe, 'p100stb'); $test = ****test****** print("<div class='text-center'> if($i==0) { <h2>$sta , $stb</h2> <---------- 1 want print once } else { continue; } $test <------------------- 1 want repeat aslong find them in database </div>"); $i++; }//while closed
Comments
Post a Comment