0

I have a horizontal table that have a changing number of columns. How do I set a fixed column width? I have tried to set width in the main table setup and in the tr and td tags. No luck so far. Any suggestions?

Here is my code

...mysql query

while ($row = mysql_fetch_assoc($result))
{
    $file_no .= '<td>'.$row['File_no'].'</td>';
    $user .= '<td>'.$row['User'].'</td>';
    $movement .='<td>'.$row['Downloaded']. " &nbsp " .$row['Uploaded'].'</td>';

    $i++;
}


echo '
<table border="1">
    <tbody>
        <tr align="center"> 
            <td align="left"><b>File no.</b></td>'.$file_no .'
        </tr>
        <tr align="center">
            <td align="left"><b>User</b></td>'.$user .'
        </tr>
         <tr align="center">
            <td align="left"><b>Movement</b></td>'.$movement .'
        </tr>
    </tbody>
</table>
';
6
  • 1
    stackoverflow.com/questions/928849/setting-table-column-width should be helpful Commented Sep 21, 2014 at 17:15
  • I have set the tr td tags to different values, f. ex. <td/tr width="100"> and the main table setup like <table width="auto" border="1"> Commented Sep 21, 2014 at 17:16
  • You forgot to close your <b> tags... Commented Sep 21, 2014 at 17:17
  • Well, I was looking for a horizontal table setup and found this. stackoverflow.com/questions/11001426/… Commented Sep 21, 2014 at 17:27
  • There is no reason why your width isn't working except the table is to wide and the columns results in smaller width because of that. Here is a test: codepad.org/ys8q8PLi Commented Sep 21, 2014 at 17:32

0

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.