Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using PHP to format query

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
I have a page that gains its content from a mysql db, take this example in the db:

This is the first paragraph.<newpara>And this is the second paragraph.<bulllet>Point One<bullet>Point Two<bullet>Point Three<newpara>This is the last paragraph.

I though if I indicated new paragraphs and bullets with <newpara> and <bullet> that I could use PHP to format it correctly with appropriate <p> and <ul><li> tags. Perhaps with explode(), but how?

Thanks.

 
Seems better, easier and better looking to do:

$text_from_db = str_replace(&quot;<bullet>&quot;, &quot;<img src=\&quot;mybullet.gif\&quot; width=\&quot;10\&quot; height=\&quot;10\&quot;>&quot;, str_replace(&quot;\n&quot;, &quot;<p>&quot;, $text_from_db));

In that case you won't have to have <newpara> in the
data. A line break will do the trick.
Also, a gif file is always better looking than
a <li> tag.

But f you want to keep with your idea, str_replace(&quot;&quot;, &quot;&quot;,$var) can be used. No need to explode I think.

Have a good day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top