Click to See Complete Forum and Search --> : td tags must be opened before closed
scragar
11-22-2004, 08:06 AM
I want to loop though a variable and tally up a count, everytime it reaches a <td it should add one, while when reaching an </td it will remove one. if the count is ever 0 when it reaches a </td it should replace it with </td and not increase the count. if at the end the loop the count is above 0 I need to wriute a nessesary no of </td>'s on the end.
anyone got any ideas as to the pesudo code required to do such a thing?
Loop through one line at a time and process accordingly.
Edit: or are you going to have more than one TD on a line?
scragar
11-23-2004, 05:04 AM
It's going to be used for a html forum, so the user may enter almost anything!
sorry, I should have mentioned that earlier.
davey
11-23-2004, 08:03 AM
please give us more of an idea what you are trying to do
Charles
11-23-2004, 08:04 AM
Originally posted by scragar
It's going to be used for a html forum, so the user may enter almost anything!
sorry, I should have mentioned that earlier. Then you'll need a full HTML / XHTML parser and you really do not want to write your own from scratch. Look around for one already written.
You could explode the string "td>" and then check each array index for "<td>" or "</td>" in a loop. Then you could do the processing you mentioned above.
scragar
11-24-2004, 07:43 AM
I'll try exploding it now, but incase anyone else wants to help below are a few details about what I need:
I have a simple HTML forum, when the user veiws a thread they all appear in a long table, for the moment it's not anywhere near completion but here's a link (http://scragar.mybesthost.com/main.php?s=forum/showthread&threadID=1) so you can see what I mean.
I have already made the code to remove JavaScript and I'm now wanting to remove the TD's that would change the alignment of the site(a single </td> too many in the post ruins it so far...)
NOTE:
if you decide to veiw the site you may find that some of the links don't work, that's because I was hoping to get the forum done first since that is the largest peice of the code and once done I would be able to do the rest quickly with the forum used for error reports. And thus since the forum is not complete few links actualy work.
Why not simply check to make sure there is a certain number of TD's in each TR?
Paul Jr
11-25-2004, 09:24 AM
Originally posted by scragar
I have already made the code to remove JavaScript and I'm now wanting to remove the TD's that would change the alignment of the site(a single </td> too many in the post ruins it so far...)
It sounds like you are trying to keep people from entering in code that might mess up your page, so why not use strip_tags() (http://www.php.net/strip-tags)? You can allow certain tags if you want (for, say, simple formatting).
scragar
11-26-2004, 03:34 AM
but then how can people add tables themselves? or links with an alt property...
I think I'll leave this for now, and just edit the post that have too many manualy from myPHPAdmin when nessesary.
Thanks for trying/helping though...
Originally posted by scragar
but then how can people add tables themselves? or links with an alt property...
I thought you didn't want people adding tables themselves? :confused:
scragar
11-27-2004, 09:09 AM
The users should be able to post their own tables just so long as it doesn't confilct with mine.
Originally posted by scragar
The users should be able to post their own tables just so long as it doesn't confilct with mine.
That's why you disable all HTML, then re-enable specific HTML (or use something like UBBC).