0

I have a form that gets emailed to me in a table format, so that it's easy to see. There are 2 cells in the table - the question and the answer (it's an application form). At the moment, the fields come through all different sizes depending on the content in them. I want to be able to specify the width of the first and the second box (first box, the question, should be smaller for example). This is an example of my code:

  $message .=  "<strong>EDUCATION</strong>";
        $message .= '<table rules="all" style="border-color: #999;"       cellpadding="10">';
        $message .= "<tr><td>School / University:</td><td>" . strip_tags($_POST['req-school']) . "</td></tr>";
        $message .= "</table>";

I thought i'd be able to just use the following:

    $message .= "<tr><td width="350px">School / University:</td><td>" . strip_tags($_POST['req-school']) . "</td></tr>";

but since there is already quotation marks it is showing as an error. I then tried using just ' but it doesn't seem to allow me to make the box any smaller than 350px. If I put 300px, it jumps down to be about 50px wide which is far too small. Please help!

user2132851
  • 75
  • 1
  • 7

3 Answers3

0

td width is deprecated since html 4.01 and you could use css to solve this. Take a look at this topic, this should help you. Set the table column width constant regardless of the amount of text in its cells?

Community
  • 1
  • 1
Mangs
  • 698
  • 1
  • 19
  • 40
  • Thank you. Isn't CSS bad to use in emails though? – user2132851 Jan 08 '14 at 22:51
  • Am trying to use CSS with it, as I think this would be much better, but my form is php and I can't seem to get the style's involved. This is what I have: $message = ''; $message = ''; And then everything else follows, but it shows as an error – user2132851 Jan 08 '14 at 23:25
0
    $message .= "<tr><td width="350px">School / University:</td><td>" . strip_tags($_POST['req-school']) . "</td></tr>";

error

have attributes that do not close

<tr><td width="350px"></td><td>" .. "</td></tr>

so should be

$message .= "<tr><td width="350">School / University:" 
. strip_tags($_POST['req-school']) . "</tr></td>";
alessandrio
  • 4,282
  • 2
  • 29
  • 40
0

The simplest fix is to omit the quotation marks around simple HTML attributes. Instead of width="350px", write width=350. (The px unit is formally invalid here. It does not prevent the attribute from working, but neither does it do any good.)

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • This doesn't work unfortunately. It doesn't give me the error message anymore, but it doesn't change the sizes – user2132851 Jan 08 '14 at 23:31
  • You then need to provide (by editing the question) a complete simple HTML example that reproduces the issue. Apart from this syntactic correction, the problem must lie outside the code snippet included now. – Jukka K. Korpela Jan 09 '14 at 00:11