Help changing something from a table to ?

Discussion in 'Programming' started by Mr.Bill, Nov 27, 2007.

  1. #1
    So I have a snippet that pulls info from the data base and then inserts into a table this table has unlimited rows and 3 columns would like to know if its possible to achieve the same output without using tables.



    
    			<table width="100%" border="0" cellspacing="0" cellpadding="0">
    				  <tr class="c1">
    					<td width="55%"><div align="left"><strong>column #1</strong></div></td>
    					<td width="25%"><div align="left"><strong>column #2</strong></div></td>
    					<td width="20%"><div align="left"><strong>column #3</strong></div></td>
    				  </tr>
    				  <?php
    					$query = mysql_query("SELECT * FROM `networks`") or die(mysql_error());
    					$counter = 1;
    					while ($row = mysql_fetch_array( $query )) 
    					{
    						echo '<tr class="'; 
    						if ($counter%2 == 1) { echo "c2"; } else { echo "c1"; } 
    						echo '">'."\n";
    						echo '<td><a href="http://'.$row['url'].'/">'.$row['name'].'</a></td>'."\n";
    						echo '<td><div>'.$row['status'].'</div></td>'."\n";
    						echo '<td>'.$row['type'].'</td>'."\n";
    						echo '</tr>'."\n";
    						$counter++;
    					}
    					echo '</table>'."\n";
    				  ?>
    				</table>
    
    Code (markup):

    Thanks in advance. Hopefully this is understandable :)
     
    Mr.Bill, Nov 27, 2007 IP
  2. EagleAmerican

    EagleAmerican Peon

    Messages:
    22
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm curious, why would you want to do this without using a table? ;)
     
    EagleAmerican, Nov 27, 2007 IP
  3. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Because it would be the only table in a template that isnt suppose to have tables :)
     
    Mr.Bill, Nov 27, 2007 IP
  4. EagleAmerican

    EagleAmerican Peon

    Messages:
    22
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm not sure of any way but raw data. Does it mess up the page with tables? There shouldn't really be anything that a table would mess up. :/
     
    EagleAmerican, Nov 27, 2007 IP
  5. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Tables are there to show tabular data. If you are calling something from a db I would assume that it is tabular data in which case a table is the correct way to display it and trying to use something else would just highlight a lack of understanding.

    If you wanted to use another method to lay it out you can and just use CSS to format the layout to make it appear like a table.
     
    AstarothSolutions, Nov 27, 2007 IP