0

I want this table of data to be displayed in 3 columns instead of 1 column as it's doing now; how would I do this with CSS ?

    <?php
     echo "<table><tr><th>Tours</th></tr>";
     while($rowTours = $resultTours->fetch_assoc()){ 
       echo "<tr><td><h4>{$rowTours['Destination']}</h4>"; 
       echo "\r\n £ {$rowTours['Price']}\r\n";
       echo "\r\n{$rowTours['Description']}"; 
       echo "<img src=\"img/{$rowTours['destimg']}\" 
                  class =\" img-circle img-thumbnail\"> 
             </td></tr>";                  
            }
     echo "</table>";
   ?> 

1
  • 1
    Add three more columns (td) in there :) Commented Dec 26, 2014 at 12:29

3 Answers 3

1
 <?php
     echo "<table>
                 <TR>
                    <TH>Destination</TH> <TH>Price</TH> <TH>Description</TH>
                 </TR>";
     while($rowTours = $resultTours->fetch_assoc()){ 
       echo "<TR>
                <TD><h4>{$rowTours['Destination']}</h4>
                      <img src=\"img/{$rowTours['destimg']}\" 
                       class =\" img-circle img-thumbnail\"> 
          </TD> 
                <TD>£ {$rowTours['Price']}</TD>
                <TD>{$rowTours['Description']}</TD>
             </TR>";                  
            }
     echo "</table>";
   ?> 
Sign up to request clarification or add additional context in comments.

Comments

1

Maybe to move tr tags outside the loop, where is table tag, like this? tr is row, td is cell in row, and i guess that you have 3 results in loop, and you wanna each in one cell (column)?

  <?php
            echo "<table><tr><th>Tours</th></tr><tr>";
           while($rowTours = $resultTours->fetch_assoc()){ 


                echo "<td><h4>{$rowTours['Destination']}</h4>"; 
                echo "\r\n £ {$rowTours['Price']}\r\n";
                echo "\r\n{$rowTours['Description']}"; 
                echo "<img src=\"img/{$rowTours['destimg']}\" class =\" img-circle img-thumbnail\"> </td>";

            }
                echo "</tr></table>";

          ?> 

Comments

0
<?php
     echo "<table><tr><th>Tours</th></tr><tr>";
     while($rowTours = $resultTours->fetch_assoc()){ 

        echo "<td><h4>{$rowTours['Destination']}</h4></td>"; 
        echo "<td>£ {$rowTours['Price']}</td>";
        echo "<td><img src=\"img/{$rowTours['destimg']}\" class =\" img-circle img-thumbnail\"> </td>";
     }
     echo "</tr></table>";

?> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.