473,789 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

grabbing html data from sql database and displaying as html

24 New Member
Hey guys,

Im making a stupidly simple CMS and i guess the best way to save data for each page is within an sql database. The only thing is, from past experience, when you echo data from a database it usually just echos the text (i.e. <font color="#FFFFFF" >Hello</font> instead of echoing Hello in white.

Anywho, if you think im going the wrong way about it please prod me in the right directions.

Cheers
Nov 23 '07 #1
4 1959
coffear
20 New Member
If the output is valid HTML then you will get the desired output. As long of course as you have not used something like html_entities.
Nov 24 '07 #2
Markus
6,050 Recognized Expert Expert
You're definitely right about the sql part! They're a godsend.

Anyways, it sounds like you are, indeed, using something like:
Expand|Select|Wrap|Line Numbers
  1. $str = "<b>html<i>html</i></b>";
  2. $strSafe = htmlentites($str)
  3. //enter $strSafe into DB
  4. //or likewise with htmlspecialchars()
  5. //you can reverse these functions with decoding
  6. //i.e
  7. //pull data from mysql
  8. $res = mysql_query("query_to_do");
  9. while($x = mysql_fetch_array($res)){
  10.   echo html_entity_decode($x['row_name']);
  11.    // or if you use htmlspecialchars() :
  12.   echo htmlspecialchars_decode($x['row_name']);
  13. }
  14.  
Hope this helps.

Note: When decoding with htmlentities() remember it's html_entity_decode

:)
Nov 24 '07 #3
code937
24 New Member
markusn00b, thanking you kindly! useful post and i think its exacly the bit of code i asked for, ill test it in a bit :)

Thanks !!!!!
Nov 25 '07 #4
Markus
6,050 Recognized Expert Expert
markusn00b, thanking you kindly! useful post and i think its exacly the bit of code i asked for, ill test it in a bit :)

Thanks !!!!!
Absolutely no problem code937.

S'what we're here for.

Post back if you need more help!

-markus
Nov 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2597
by: Joe | last post by:
I need to connect to 10 web sites to grab content from them. I would like to connect to each site simultaneously so that I can obtain the data as fast as possible. I am familar doing this with perl by using parallel sockets or the module LWP-Parallel. So what would be the best method to do this in php? Sockets, forks? Also, if possible, could someone provide me with a good reference site that will help me accomplish this?
3
1857
by: vishal | last post by:
i am creating a news site. i am adding new news in database and it must be visible to user at top. and then second latest news and so on. i am displaying 15 news on each page and then put a link for next 15 news on page. my site is accessed by millions of people everyday. so for each when he want to see news he click on news link and in my php program query is run in database. so my database access became very slow because if one...
4
2484
by: jason | last post by:
I would appreciate some help on how to convert a database table into an html file via FSO and whether more seasoned asp programmers recommned this route. The main reason I am attempting to do this is becuase we are constantly being told by so-called marketing gurus that 'html' pages are more search engine friendly. Other advantages include speed of download. Will there be any problems with using this approach besides establishing...
9
2151
by: BCS | last post by:
I have a web site in which the site administrator can input information to a database through a web form. The information then gets displayed on ASP pages. One field is a large text field. Of course, without html tags, the text gets displayed on the web page as one long paragraph since the database doesn't store any line breaks or paragraph breaks. The obvious solution (to me) is to use html tags like <br> in the input. However, while...
5
7866
by: Tomaz Koritnik | last post by:
Hi I have many short HTML files stored in a binary stream storage to display descriptions for various items in application. HTML would be display inside application using some .NET control or COM control (like Microsoft WebBrowser). For each description there is one HTML file and along description text, it contains links to related information. Clicking related information would for example open new form in application and display some...
4
1393
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it appears that you grab the values directly from the form objects on the postback. Here's our problem:
5
1543
by: Rik Brooks | last post by:
I am writing a web application using C#. I've come to the point that I need to display some html text that is stored in a database. Is there a server side control that I can use to show the html? In other words, read the data, then set the Text property (or something else) and it displays in the window -- ---------------------------------------- Magic is not in the hands of the magician but in the mind of the audience. Animadverto est...
5
1922
by: joe_doufu | last post by:
Hi, old web developer, new to Ajax and XML here. I'm developing an application that grabs an XML file from a (PHP) web service. In fact, it's going to be an online game. When the user clicks a map location it accesses a service that provides information about that location in a form something like this: <maplocation locID="###" picturesrc="image.jpg"> <name>...</name> <breadcrumbs>...</breadcrumbs> <description>...</description>
4
2075
by: sgjwm | last post by:
I'm trying to set up a program to automatically grab a few data files from a data provider on a daily basis. There are however, several obstacles to this: 1) The site requires a login / password, so it's not just a simple grab a page and parse it. 2) There's a lot of javascript involved, and in multiple frames on the page. 3) It doesn't simply just display the data on the page either. There's 2 options to retrieve the data that I can...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9499
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10121
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5539
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.