tags:

views:

56

answers:

4

i have one table in loop which come under li>

   <?php
 for($i=1;$i<=$tc;$i++)
 {
  $row=mysql_fetch_array($result);
  ?>
  <li style="list-style:none; margin-left:-20px">
  <table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
 <td class="hline" style="width:267px"><?php  echo $row['tit'] .",". $row['name'] ?></td>
<td class="vline" style="width:1px">&nbsp;</td>
<td class="hline" style="width:100px"><?php echo $row['city']; ?></td>
  </tr>
 </table>
</li>
<?php
}
?>

the out put comes like this

alt text

  • i can't put table outside the loop, due to li> sorting

thanks

+1  A: 

i can't put table outside the loop.

Why not? This is where it belongs. After all, you (logically) produce one table, not many of them. No need for the list item, either.

Konrad Rudolph
A: 

li tag is required?

<table width="600" border="0" cellspacing="0" cellpadding="0" style="margin-left: -20px;" >
<?php
or($i=1;$i<=$tc;$i++)
{
  $row=mysql_fetch_array($result);
  ?>
  <tr>
<td class="hline" style="width:267px"><?php  echo $row['tit'] .",". $row['name'] ?></td>
<td class="vline" style="width:1px">&nbsp;</td>
<td class="hline" style="width:100px"><?php echo $row['city']; ?></td>
  </tr>
<?php
}
?>
</table>
gmunkhbaatarmn
A: 

If you're unable to put the table outside of the loop, you should probably just use tags rather than creating tables, as you're defeating the purpose of even having a table by making each table a single row and trying to stack them.

Another thing to note if you are going to stick with tables:

If you're hard-coding the table width AND all of the table cell (column) widths, it may cause unexpected issues when they don't add up:

Table width = 600px

Cells = 267 + 1 + 100 = 368px

AvatarKava
+1  A: 

if you can't use table outside the loop then i think best option will be use of

     <div>

statement

for example

   <div class="q-s na">
     <div class="st" style="margin-right:10px; width:150px">
        <div class="m-c"><?php  echo $row['tit'] .",". $row['name'] ?></div>
    </div>

this will be same as you one

      <td>

you can define style according to your requirements.

for example

        <style>
    .q-s{overflow:hidden;width:664px;float:left; 
         padding-top:2px; padding-bottom:2px; height:25px}

      .na .st{ float:left;}
   .na .m-c {border-bottom:1px dotted #999; padding-bottom:10px; height:15px}
    </style>