vendredi 3 avril 2015

Browser is creating tr for td which is without tr?


Vote count:

0




I am trying to make 2 column layout of table using php loop so it is conditional also. I am unable to create two columns as browser automatically inserts tr for tds without having trs, May be I am missing something...


my code



<?php $i=0; while($row = $result->fetch_assoc()){ ?>
<?php if($i % 2){ echo "<tr>"; echo $i;} ?>
<td><?= $row['Zip_Code']?></td>
<td><input type="checkbox" name="zipcode[]" id="zip_<?= $row['Zip_Code']?>" value="<?= $row['Zip_Code']?>" <?php echo (in_array($row['Zip_Code'], $zipcodes))? 'checked':'';?> ><label class="zip_label" for="zip_<?= $row['Zip_Code']?>"></label></td>
<?php if($i % 2){ echo "</tr>"; } ?>
<?php $i++; } ?>


My Desired output



<tr>
<td>blah </td>
<td>blah </td>
<td>blah </td>
<td>blah </td>
</tr>


but it shows me like this



<tr>
<td>blah </td>
<td>blah </td>
</tr>


asked 27 secs ago

MWT

201






Browser is creating tr for td which is without tr?

Aucun commentaire:

Enregistrer un commentaire