我在MySQL表中有35條狀態名記錄。我劃分了數據轉換成兩列 這裏是要求將一列數據劃分爲四列
<td>
<table class="statetable">
<?
//******Fetching State Name Dynamically*****//
$fetchstate = mysql_query("SELECT LocationName FROM servicedesklocationmaster group by LocationName ASC");
$half1 = floor(mysql_num_rows($fetchstate)/2);
echo $half1;
$count = 0;
// First Half State
while($count <= $half1 && $row = mysql_fetch_array($fetchstate))
{
$statename = $row['LocationName'];
$count++;
?>
<tr>
<td>
<font size="1.5">
<input type="checkbox" name="Location[]" id="Location" checked value="<?php echo $statename;?>" onClick="CheckEachAsset()"><?php echo $statename;?><br>
</font>
</td>
<?
}
//echo $count;
?>
</tr>
</table>
</td>
<td>
<table class="statetable">
<?
// Second Half State
while($row = mysql_fetch_array($fetchstate))
{
$statename = $row['LocationName'];
?>
<tr>
<td>
<font size="1.5">
<input type="checkbox" name="Location[]" id="Location"
checked value="<?php echo $statename;?>" onClick="CheckEachAsset()"><?php echo $statename;?><br>
</font>
</td>
<?
}
?>
</tr>
</table>
</td>
我的PHP代碼現在按我的新的要求,我想這個分成4列可有人建議我 如何實現
試試'modulo''%'操作符 – swapnesh
可以在代碼中詳細說明嗎? – Mac