Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Display Html Text From DB


I've got a text box and basically the user types text in html format, I then use htmlspecialchars to convert special characters to HTML entities, fine not a problem I then store the text in a DB with the HTML entities in place.

However when I want to display the text from the DB it still has the HTML tags in place and would like to render the HTML so to speak, how do I implement this? Sounds straightforward but need some pointers.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Storing Some Html Text In Database & Display Them
i have some text in HTML format ..i just want to store HTML text in database and retrive and display them as a HTML ...

Read And Display Japanese Text From Text File
I posted a question regarding reading japanese
text from a text file.

Well, since I solved the problem, I thought I'd post my solution for
the benefit of other people with the same problem.

The plan was to make a script to read and display japanese text. I
will use it for making a japanese proverb script and for a japanese
language study script.

Method :

I wrote a simple kanji text file (saved with UTF-8 encoding)
I wrote a simple PHP script to display the file contents (saved with
UTF-8
encoding)
I specified the content-type header for the HTML page :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

*** All files have the same encoding. ***

UTF-8 supports japanese characters.

and it works!

this is my PHP (and HTML) script :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP : Japanese Text File Read : Exercise 1</title>
</head>
<body>

<?php

$filename="japanese.txt";
//open file
$fp = fopen($filename,'r');

//loop through each line in the file
while($line=fgets($fp))
{
//output current text file line
print $line."<br>";
}
//close file handle
fclose($fp);

?>

</body>
</html>

I know it's a very simple script, for testing purposes only. It
displays the contents of the japanese text file line by line.

The key was to save all files in the same encoding (I used UTF-8) and
to specify the encoding / charset in the HTML header (<meta
http-equiv="Content-Type" content="text/html; charset=utf-8">)

Text File Display
I have a number of SQL reports that create standard 132 column text files. The user wishes to view these files in a browser in addition to their daily printing on a laser printer.

I can handle directory structure, etc with PHP but I would like to know what is the best way of displaying these text files on screen. We can select them but they are very plain. Is there a TXT2HTML ot TXT2XML type tool that can display headings, bolding, etc without too much difficulty. I would rather not reprogram the reports as there are hundreds of them, and embedding HTML would not be an answer as they need to be printed on a regular laser.

Using PHP To Display News Text
I downloaded a php script from hot scripts called Blue Boy Whats New. I really like what he's done on his site for displaying news items.

I got the admin part working and can add and edit news items. I can view the page created
bb_news.php3, but when I try to include the php3 file in my home page nothing shows up.

Japanese Text Display
I have Japanese data coming from a mySQL database. It's internal encoding is EUC-JP and it is outputted as SJIS. This actually works just fine. My question comes from the fact that once these changes were made, all the static Japanese text on the page is botched. The meta tag in the head is set to Shift_JIS(SJIS) and it worked before the change.

Any suggestions? I just can't see how the two match up... The encoding of the db info shouldn't affect the encoding of static info on the page should it? Especially when they are both output in the same encoding..

How Not To Display HTML?
I've created an admin area where I can edit currently posted news. I have all my news listed in a table with the variables $newsid, $title, $content.

$content is saved in the database as html code. Is there anyway of displaying the html code without in executing. E.g. When I pull $content it displays:

<b>Today</b> I went to the shops.<br />They were closed.
Instead of: Today I went to the shops. They were closed.

How To Cut Text And Display It Plus The Remaining Texts
just wanna ask if there's a way I can limit the text length i wanna display and display the remaining text below...??

let's say here's my string:

$CallNum = $rows['CallNum'];

this contains : Q179:1546:554-abc

now i want to display this text like this:

Q179:
1546:
554-
abc

Display A Text File On A Web Page
I have a text file that I am trying to display on a web page. If I cat
or more the file it formats and displays fine. When it comes up in the
browser it seems to loose tabs and the format gets messed up. This is
how I display the file.

$show = file("./fields/combined/$cdp$store");
$arrayitems = sizeof($show);
$x=0;
while ($x < $arrayitems) {
print("$show[$x]
");
$x++;
}

If I edit the file it has ^M at the end of each line if it matters.
Does anyone have a better idea as to how to display it?

Display Text In Firebird BLOB
I have a Firebird 2.o Database. When I display the text content of a BLOB field, I get the following result.
{
tf1fbidisansiansicpg1252deff0{fonttbl{f0fswissfprq2fcharset0 Helvetica;}{f1fswissfprq2fcharset0 Calibri;}{f2fnil MS Sans Serif;}} {colortbl ;
ed0green0lue128;} viewkind4uc1pardltrparqclang1033f0fs22 DURBANVILLE CONGREGATIONpar DEDICATED 28TH NOVEMBER 1999par.

I use ibase_blob_echo to return a result. How can I get the result to display witout the rtf characters.

Display HTML Before PHP Output?
I have a menu that outputs an RSS newsfeed using a PHP script (CaRP -
however it ALWAYS displays the PHP
outputted HTML before the embedded HTML. This happens regardless of the
order; HTML first PHP second, or visa versa. I am assuming that the PHP
engine writes the PHP output first by default??

Is there a way to force the PHP to output in the order it is
"written"...at least, can I control it?

Best Way To Display HTML Tags?
I am trying to display the source of HTML files withing pages on my site. What is the best way to display the code so that it doesen't get parsed as HTML?

Display MS WORD Into Html
i am having a .doc file called one.doc it contain a CV of the student. now i want to display it in the browser. that is this is your CV preview. check it.

How To Display Text On Browser After Forcing Download
how do i display text to my browser after i force a download? heres my working script:
Code:

$selected_file = "/home/user/somelogfile.log";
header("Content-Type: text/plain");
header("Content-Disposition: attachment; filename=" . $_SERVER[HTTP_HOST] . "_" . $selected_file);
header("Content-length: " . filesize($selected_file));
readfile("$selected_file");

what i want to do is display some text in my browser, but if i echo something after readfile(), it gets included in the download file, while i also cant echo before the download as headers need to be sent before any text .

Display MySQL Data In Text Field
I have my site set up and am now working on the admin side. I have a page that lets me search my users then its linked to another page so I can edit the information.

I am attempting to get the code to display in my forms text boxes and text areas for updating. My problem is that I can't figure out how to get the data into my form for editing. I have a few different things but can't seem to figure this out.

Mail () Display All Html Codes
i'm using the mail() to send mail to customer once they confirmed their orders.

my problem is, i wnat to display my mails with tables but when i received the email, it display out all the html codes.

PHP-gen'd Images Won't Display In HTML
I have an image-generating script myimage.php that's worked and that I've
used for years. All it does is increment a counter file and output a single
pixel in the color I provide. But on one particular web server I uploaded
to, the behavior is strange.

If I enter the URL http://www.domain.ext/myimage.php, the picture is
displayed as expected. But if I insert the script into HTML, like <img
src="myimage.php">, it fails to display and I get the broken image icon,
instead.

This has never happened before, but I do not know enough about PHP builds
and web server settings to figure this out.....

PHP To Display Images In Html Docs
I am trying to display images in an html page using a
php script. The output on the screen is bizarre:

This code works on its own:
<?
$pic = "flower.jpg"
echo file_get_contents ($pic);
?>

the above actually displays the image flower.jpg
without a problem.

But when I include the same script in an html page
the screen is filled with all sorts of characters

Something like this:
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/jpg;
charset=windows-1252">
</HEAD>
<BODY>
<?
$pic = "flower.jpg"
echo file_get_contents ($pic);
?>
</BODY>
</HTML>

Have tried another charset e.g. "charset=utf-8"
instead of "charset=windows-1252",
but to no avail.

What is the problem? Is there a way of getting the
image to work via php *inside* an html document?

Display A New Html, After The Data Is Store?
I want to know how to call a HTML file in php.
I know how to create it, but how can i call and display the newly
created HTML, which contained the data that a user just entered?
What command should i use?

Display PHP Code In HTML With Limitations
Does anyone know of a way to display PHP code in HTML without using: includes, JavaScript, or iframes? The HTML page I am trying to add PHP code to does allow XML; although I really do not know a lot about XML. Can XML be used and if so, how would I do this or is there some other methods I can use?

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

Identify Url Written In Text Area And Display It Hyperlinked.
I am using html textarea control. user writes text in text area and i save it in database using php, then i display it where ever it is required. I want if user writes some url in the area like www.abc.com or http://www.abc.com , When i display this text as output this url must be shown there as hyperlink. by clicking over it user must be redirected to www.abc .com

Is there any html textarea control property that can do it, or i need to write some php or javascript code for it. If someone has php script for it please help. It is urgent.

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

Display Results From Query In HTML-table
I'm working with PHP3 and Oracle 8. Can anyone tell me how to display the results from a query into my HTML-table?

List Of Sybmols Like To Display > On Html Page &gt And Which Are Others
i am making an application.

the user can give description and that description is stored in
database and then the description is shown on html page.

suppose the user has written "<b>hello</b>" in description then in the
database the following will be stored "<b>hello</b>" but when i display
it on database the hello in bold letter will be displayed.

i know the soultion that i have to replace the occurrences of < with
&lt and occurrences of > with &gt but i don't know that which are other
symbols which needs some repair like above so please give me a list of
html symbols and their equivalent symbol.

Getting Results To Display In Two Columns Of A HTML Table
How can i get the following script to display in two columns of a HTML table? At the moment i have it displaying in one column. If there are 5 results from the DB then the left HTML table column will display the 1st, 3rd and 5th result. The right HTML table column will display the 2nd and 4th results. Code:

Display Sql Query Output In Html Table
As evident from a previous post, I am a php noob. I would like to
display MySQL query results in an html table with one of the row values as a
category and the rest of the data displayed under the relevant category.

I can get as far as displaying the data in a nice readable format but I
don't know how to have the records placed under their corresponding
category. This is my code thus far (sans the html output):

....ORDER BY cat ASC'
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("%s Class: %s Description: %s", $row["cat"]$row["title"],
$row["desc"]);
}

Header Problem - Want To Display Html AND Download A File
I have a page that displays a form for user to select individual
fields and to specify their own criteria which is used to query a
database and then create an excel spreadsheet and download it to their
PC.

when the user clicks on the "create a custom query" link on the
reports page the file customss.php displays the form that list the
various fields and criteria to specify for the search. This part
works fine.

once the user clicks the button to submit the query the file
customssdisplay.php generates the Excel file and then sends it to the
client PC.

The problem is that once the user cliks the button to submit the
query, the form which displays the list of available criteria and
fields is still displayed EVEN AFTER the spreadsheet has been
downloaded to the PC.

Here's what I would like to happen is:

1)user clicks button to create the custom query

2)the form is displayed for the user to check fields for inclusion and
specify search criteria.

3)user chooses what they want and then clicks "submit query"

4)******* A page displays saying something like "Generating
report...."

5)Excel File is sent to user's PC.

OK now I've tried specifying a bit of html in the customssdisplay.php
file that generates the spreadsheet but this gives me error messages
saying that the header has already been sent. I suppose I could
create a passthrough file which creates a form with all the fields
hidden (taken from the search criteria page) but this seems cumbersome
and inefficient.

Entering Html And Php Into A Db And Display This In A Textarea Without It Being Processed As Code
how can i enter html and php into a db and display this within a
TEXTAREA without it being processed as code? do i need to replace
characters like <? with something else like say <..? or is there a more
elegant solution that tells the php parser etc to ignore this section
as it needs to be processed as text not code.

How To Display Html Form Selects (via Checkbox) In Email?
I have a simple form to collect user selections in html form. I am
pretty new to php...how can I send the user's checkbox selects to me
in an email...I am struggling with buiding an array to send this info...

Can We Display Text In Form Of Wave As Shown In Gmail Forgot Password
https://www.google.com/accounts/Ren...aForPasswdReset , here characters are shown in wave nature.

Display Database Output In Mutli Column Html Table
I am building an HTML form using data from a mysql query. The data to be displayed on the form is 1 column from the db - but multiple rows. Because there are many rows (well, only about 100+) in the table I want to be able to put 2 or 3 (space permitting) rows from the result on each row of the HTML table with a checkbox beside each entry from the db table. The idea is that the user will scroll down the list and check up to 4 or 5 boxes before submitting the form and I didn't want them to have to scroll ALLLL the way to the bottom (100+ rows). I understand how to get data from a db table and put it into an html table, but I cannot figur out how to put more than 1 row from the result on to the same row of the html table.

I hope I haven't confused anyone reading this -- If I am way off base with what I am trying to do please give me alternatives. I am trying to avoid paginating the data for a couple reasons a) clicking a next and/or prev button is more hassle than just scolling down a list and b) the data in the column being displayed is only about 35 - 40 characters and it seems to be if i only placed one result row on each html table row, there would be a lot of wasted space.

Extract And Display A Number From A HTML File - Regular Expression
I'm just wondering what the best way is to extract and display a
number from a html file.

I tried the following piece of code, however it does not work.

ereg('d.d', $content, $reg);
echo $reg[0];

How To Fix PHP/HTML Webpages That Display Word Resumes With Funky Characters
I have a textarea where people can cut & paste their resume.
Unfortunately they often cut & paste their Word resume into the
textarea, funky characters and all.

This causes the display to be mangled from the HTML end when people
view pages with these resumes stored as a MySQL text field entry.

How do I fix this, also, how do I fix the displays of those already
entered this way?

Get And Html Text
I've to send many emails using a script that refresh every n seconds to
avoid server timeout (can't be bypassed).

Now, I've a loop wich detects how long does the script (a loop) takes to
run. If the script is close to the 25 seconds, then I redirect to itself
passing some values.

One of the value is some html code. Then I get it in variable, add some
text and so on, until threre is no more values in the database.

Now, passing the variables I do this:

($message contains the HTML code).

header('location:'.$_SERVER['PHP_SELF'].'?message='.$message);

but doing a $message = $_GET['message']; I get nothing in the $message
variable.
why ? any idea?

I've tried to do so:
header('location:'.$_SERVER['PHP_SELF'].'?message='.htmlentities($message));

(I added htmlentities function) but it doesn't work.

Any idea why ?



HTML Is Trunctating PHP Text
Does anybody know why the text box on this page is trunctating $test to
Mary?

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-
1252">
<title>New Page 1</title>
</head>
<body>
<?php
$test = "Mary had a little lamb";
?>
<form method="POST" action="edit_user.php"
<p><input type="text" name="T1" size="30" value=<?php echo $test;
?> tabindex="1"><input type="submit" value="Submit" name="B1"><input
type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>

Replacing A Html Tag With Text
I need to change a html-tag into a call to a script.

Tag is like this:
<img src="someattach.php?s=3421543&id=20103" border="no">

Has to be changed to:
<?php
include("someattach.php?s=3421543&id=20103")
?>

I am thinking about preg_replace for it, but I have never used this function.

Outputting HTML And Text?
I was trying to experiment with the "readfile()" function, and I managed to output a .swf flash file. I needed to do more than just that though, I needed to add a bit of text to it. Code:

Converting Rich Text To Html
I want to do is upload a rich text file to the server and have PHP covert the text to format html for the body copy of a page. I was thinking about people just using Word or something like it and save as a rich text, then they upload it.

How To Read HTML Email Text?
I've done a couple of hours web-searching without turning up many
answers so far, and I guess I could figure it out (eventually) from
the MIME format, but here goes with my question...

I don't have any problems reading text emails, but can anybody direct
me to some PHP source code that will read (the text inside) an HTML
email, specifically the "From", "Subject" and especially the message
body?

I would like the code to be able to differentiate between (i.e. know
that it is) a text or an HTML email, and I would like the code to
ignore any attachments.

I don't expect the incoming email to have any (or large) attachments,
but I hope that any code samples can handle the possible case of big
attachments coming along for the ride.

Incidentally, if I did (not this time) want to handle large
attachments, can PHP and/or servers handle megabytes of data being
read into a string variable through fread()? I'm just getting into
this stuff, and not sure of what areas would be a resource and/or
performance hog.

Inserting Text Into A Html File
I'm building an indexing search engine that indexes via meta tags. What I'd like to do is have a script that could add meta tags to the header section of an HTML file.

I know you can write to either the beginning or end of a file, but how do I search for a specific spot and place the cursor there? There are a lot of pre-existing HTML files that need to be indexed, so having this script will help ten fold.

Text To Html Hyperlinks On The Fly For Editors
Trying to create a CMS for editors of our website, using php/mysql, there's a content text area which allows them to enter content and formats it using nl2br, but I was wondering if theres a way I can shorten hyperlinks, so that they don't have to add "<a href..." every time to their content. Something like having them enter link(http://www.bbc.co.uk, the BBC) will enter <a href="http://www.bbc.co.uk">the bbc</a> in the content... any ideas?

Function To Format Text As Html?
Is there a function in PHP that will format text in basic HTML automatically for you?
I'm pulling an article piece of text from MySQL and on display, it doesn't break at paragraphs. I know the returns are there, because when I browse the data in PHPMyAdmin, the text is broken into paraphraphs.

I'd rather not insert html into the text in MySQL as I may use this text for other purposes like print. Is there and html tag that I'm missing that would do this besides <pre>?

How Do You Filter Html From A Text Box After Submission?
I am making a forum and the users in the forum can post html. I need a way inwhich i can stop them doing so, something that will filter the html. Any ideas?

Searching HTML Code For Text
I have outputted the contents of my Winamp playlist into an HTML file. I have noticed that the songs are the only text surrounded by plain <TD> tags.

I was wondering if there was a way to go through the code and using a WHILE statement or something, input each song into a database by selecting anything between the <TD> and </TD> tags.

Displaying Text/html In Web POP Email
is it possible that message from web POP mail ( through sockets) appears as html (or text) if it is sent as html, not to appear like source file of the html document? I use web POP mail which is not mine and it displays without problem emails sent as text/plain but shows complete source with all tags if the email is sent as text/html, in other words, it´s useless and very hard to read for user.

Text Data Containing HTML Tags?
I am working on a content system. But cannot seem to figure out how to display text that has html formatting tags included. I use a form and the TEXTAREA to have users submit text. I save it to a MySQL db.

I want the user to be able to use html tags such as <B></B>, but when I display what was saved, the HTML tags do not function. I have read about addslashes(), and removeslashes(), but am not sure I fully understand them. Should I be trying these?

Full-text Indexing Of Pdf, Rtf, Txt, Html
I have a big pile of files on my local machine that are in a variety of
formats - txt, rtf, pdf, html, etc. What I'm looking for is a script
that will crawl through the files and perform simple full-text indexing
on them, and will allow for queries to be executed on the index.

I gave PHPDig a shot but it prefers web-based setups - my files are all
stored locally and will only be accessed locally.

Function To Add HTML Tags To Text
i have 4 fields (noun1, noun2, noun3, verb1) for a person to fill out and what they put into these fields will be printed out at certain points throughout a quotation (basically, it's a madlib with quotes from the simpsons and futurama).  after the four fields, i allow them to select from a drop-down select menu with the options of bold, underlined, italics. 

what i need done is that IF they select any of those, i need what is printed out from the fields to be printed out with HTML tag formats ().

Writing Syntax Text/html
Below is my insert script. The problem I'm facing is that when I input, "<a href="test">TEST[/url]" the DB writes "&lt;a href="test"&gt;TEST&lt;/a&gt;" and I want it to write exactly what I input:

$sql_comm="INSERT INTO `sc_postcomment_member` ( `scm_mem_id`, `comment`, `post_date`, `comm_from`) VALUES ('$scm_mem_id', '$txt_comment', UNIX_TIMESTAMP(), '$social_mem_id')";
$res_comm=$db->insert_data($sql_comm);


Copyright © 2005-08 www.BigResource.com, All rights reserved