Reply to Re: Table in MySql database

Your name:

Reply:


Posted by Geoff Berrow on 07/09/05 17:00

I noticed that Message-ID:
<daoe9j$70g$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com> from Margaret
contained the following:

>I have a PHP script written by my Nephew (now in the USA working in a
>summer camp so unavailable) which gets information from a database. I
>can add all the stuff I need to the database and in the "longtext" field
>can add html tags and so on and all works fine. But when I try to get a
>table into it I works OK but a heap of <br> are added in before the
>table shows meaning that I have to scroll right down the page to be able
>to see anything.

If you type in text into the longtext field, line breaks have to be
translated into <br /> tags other wise they would not show in html. The
trouble is, the function that does the translation does not know you are
pasting a table and happily converts all the line breaks to <br />.

Now if you remove the nl2br() function then it will prevent it happening
for those entries that need it. What you need is something that will
apply the function only if it is needed. The exact way you do this
depends on how the nl2br() function has been applied in the code.

For instance you might have:-

echo nl2br($myrow['longdesc']);

in this case you could do something like:-

//check if the data contains the string '<table'
if(strpos($myrow['longdesc'], "<table")===false){
//if it doesn't, we need the <br /> tags
echo nl2br($myrow['longdesc']);
}
else{
//we don't need any <br /> tags
echo $myrow['longdesc'];
}

Note that this assumes that the string '<table' will only occur when you
are actually using a table and will not occur when you are not.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация