I currently have a problem with splitting data that is retrieved from database.
Example: when I display it, it shows data1 data2 data3 data4. But I want it to be displayed like
- Data1 Data2
- Data3 Data4
I have tried several ways to do it, but I failed to do so. Is there anything I have to change in my code in order to achieve that?
Here is my code:
<table class="table">
function pingAddress($ip,$kiosk) {
$fp = @fSockOpen($ip,80,$errno,$errstr,1);
$checkCount = 0;
if(is_resource($fp)){
if($fp) {
$status=0;
fclose($fp);
echo '<td><p><b>'.$kiosk.'</b></p><img src="images/green.png" width=50px height=50px></img></td>';
$checkCount++;
}
}
else{
echo '<td><p><b>'.$kiosk.'</b></p><img src="images/red.png" width=50px height=50px></img></td>';
$checkCount++;
}
if($checkCount % 2 ==0){
echo '</table><table class="table">';
}
}
// Some IP Address
pingAddress("192.168.1.0","Kuantan (35)");
pingAddress("192.168.1.1","UTC Kuantan (36)");
pingAddress("192.168.1.2","Temerloh (37)");
pingAddress("192.168.1.3","Bentong (6)");
</table>
The result should be shown like this:
- Kuantan 35 UTC Kuantan 36
- Temerloh 37 Bentong 6
<tr></tr>.