RE: newbie problem - extraneous newlines inserted in PHP-generated HTML form source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do a var_dump() on $teachingstaff and see what is actually in the PHP array.

(I'd recommend putting the output in <pre> tags for readability).

Edward

> -----Original Message-----
> From: Mark White [mailto:mwdesign@xxxxxxxxxxx]
> Sent: 21 November 2006 16:32
> To: php-general@xxxxxxxxxxxxx
> Subject:  newbie problem - extraneous newlines inserted in
> PHP-generated HTML form source
> 
> 
> hi
> 
> I am VERY new to this, so please be gentle.
> 
> I am trying to use PHP to generate an HTML form for editing an 
> uncomplicated XML document. I can parse the xml information 
> successfully. However, when it comes to building the form, where I have 
> a pair of double quotes (one escaped) to open the insertion of an array 
> variable for a form value there is also a newline character inserted in 
> the generated HTML form source code. Firefox and Safari ignore the 
> 'breaks' in the code lines but it causes Explorer 5.2 (Mac) to fail to 
> display the values.
> 
> I have tried replacing the escaped double quote with a single quote - no 
> change, the HTML source still includes the extra newline. I've tried 
> removing and inserting spaces either side of the '.' without luck. I've 
> also checked the xml document in Textwrangler and it is 'clean' of 
> unwanted hidden characters.
> 
> There are two oddities about this. Firstly, the array[0] postion record 
> set form doesn't produce this 'broken' generated HTML, yet subsequent 
> records each show breaks in the HTML source in exactly the same place. 
> The other strangeness is that if I tab the original xml document for 
> clarity I get tabs inserted in the HTML along with the extra return .... 
> but again, only from record 2 (array[1]) onwards.
> 
> Here is part of the xml -
> 
> <?xml version="1.0"?>
> 
> <teachingstaff>
> <person>
> <name>name 1</name>
> <status>headteacher</status>
> <class>1</class>
> <history>words here</history>
> <picture>1.jpg</picture>
> </person>
> <person>
> <name>name 2</name>
> <status>teacher</status>
> <class>2</class>
> <history>words here</history>
> <picture>2.jpg</picture>
> </person>
> <person>
> <name>name 3</name>
> 
> and so on ... and here is some of the php to generate the HTML editing 
> form -
> 
> <?
> loadteachingstaff();
> echo "<div id=\"container\">";
> echo "<div class=\"head\"><h2>Edit staff listing</h2></div><div>\n";
> if($tstaffid < count($teachingstaff)) {
> echo "<form action=\"tstaffsave.php\" method=\"POST\">";
> echo "<input type=\"hidden\" name=\"tstaffid\" value=\"$tstaffid\">";
> echo "<table>\n<tr><td class=\"labelr\">Name: </td><td><input 
> type=\"text\" name=\"newname\" size=\"50\" 
> value=\"".$teachingstaff[$tstaffid]['name']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Role: </td><td><input type=\"text\" 
> name=\"newstatus\" size=\"50\" 
> value=\"".$teachingstaff[$tstaffid]['status']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Class(es): </td><td><input type=\"text\" 
> name=\"newclass\" size=\"50\" 
> value=\"".$teachingstaff[$tstaffid]['class']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\" valign=\"top\">Experience: 
> </td><td><textarea name=\"newhistory\" rows=\"5\" cols=\"50\" 
> align=\"left\">" . $teachingstaff[$tstaffid]['history'] . 
> "</textarea></td><br /></tr>\n";
> 
> and so on ...
> 
> The (**NEWLINE**) 'break' in the generated HTML source appears at the 
> following point in each of the echoed lines -
> ...
> name=\"newstatus\" size=\"50\" 
> value=\""**NEWLINE**.$teachingstaff[$tstaffid]['status']."\"></td>
> </tr><br 
> />\n";
> ...
> 
> ... but NOT if $tstaffid is 0 ...
> 
> Sorry to be so long-winded. I've checked the FAQ archives and can't find 
> anything which helps.
> 
> Mark
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux