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




Bold/Italic/Underline Buttons For Text Field.


How would I go about making buttons (much like the ones above where you type posts/replies on this or any other message board) that would insert HTML code for:<b>, <i>, <u> etc, wherever the user's cursor is at within the text field?...Is that even PHP? Or another web technology all together?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Highlighting Text And Bold/underline/italicize
I set up a new forum using phpBB 2.0.22. The highlighting and bold/italics/underline function is not working correctly. On other phpBB forums, if I am writing a paragraph and decide to underline a word for emphasis, I simply highlight that word, click the "U" button up top, and it inserts the underlined tags around the highlighted word, making it underlined. I noticed this forum works that way as well. Unfortunately, my forum does not. 

If I highlight a word and then click "U" for underline, it does not insert the underline tags around the word, but rather places the tags at the end of the text. So instead of looking like this:

I am trying to underline some text

it instead looks like this:

I am trying to underline some text [b ] [ /b]

I added spaces in the underline tags in the example so it would show up as tags.

Is there any way to fix this?

Also, I've noticed (on my forum) that if I put the cursor somewhere in my post and attempt to insert an emoticon/smiley, it places the smiley face at the end of the text, and not where I want it. Example. I will post some text below and then go back and place the cursor in between two words and insert a smiley face:

I utterly despise tech stuff  because it confuses me. Luckily, there are cool tech people out there to help.

It placed the emoticon properly. On my forum, if I clicked between the words "stuff" and "because" and then clicked a smiley face, here's what it would look like instead of what I intended.

Bold, Italics, Underline Str_replac'd Using The Same Char For Opening And Closing Tags
I want to write a _very_ simple text parser that would replace a
string like:

"This is text with /italics/, *bold* and _underline_."

and generate automatically something like this:

"This is text with <i>italics</i>, <b>bold</b> and <span
class="underline">underline</span>."

I've found a lot of code snippets explaining how to do BBCode, but
BBCode has different opening and closing pseudo-tags. In my example,
the opening and closing tags are the same (either /, * or _). So I
need something slightly more intelligent that would count the number
of /, * or _ tags, see if that number is even or odd and decide
accordingly if it must replace the char with an opening or closing
tag. (I hope my wording makes sense. It's very clear in my head :-D)

How would you implement that? I reckon it can't be hard, but I just
can't figure how to do it right now!

Regular Expression To Underline A Given Word In A Text...
With the sentence :

"Bordeaux est au bord de l'eau"

How to do to underline, for instance, the word "eau" ? without underlining
the substring of "Bordeaux" ?
I don't know how to isolate the word...

My current code :

$text=eregi_replace("(".stripslashes($word_to_underline]).")","<b></b>",$
text);

but this underline "eau" in "Bordeaux" too and i don't want to !

Help? How To Create Next Buttons When Using A Flat Text Database
Ok, I know the code below does not work but I am wondering about the logic...

1 How do I just print 10 rows.
2 How do I get the buttons.

You get the Idea. Anyway, I would like to know if anyone has done this with text files. I always see mysql as examples but nothing using a flat text database.

<?
$maxResults = 10;
$datafile = "sometextfile.txt";

$rows = @file($datafile);
for($size=0;$size<count($rows);$size++) {
$rows[$size] = chop($rows[$size]);
$coll = split("|",$rows[$size]);


// print something

}
if ($size > 0) {
$currPage = $size / $maxResults;
if ($currPage > 1)
print("<A HREF="test.php" >['prev']</A>");
for ($i = 0; $i < $size / $maxResults; $i++) {
if ($currPage == $i + 1)
printf("<A HREF="test.php"> </A> ",$i + 1);
else
printf("<A HREF="test.php"> </A> ",$i + 1);
}
if ($currPage < size / $maxResults)
print("<A HREF="test.php">['next']</A>);
}
?>

Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Looking For A Forum-style Text Editor With BB Code Buttons
I've been hunting around the Internet for a few hours looking for a text editor with BB code buttons, similar to ones you'll find in basic forums. I've tried several WYSIWYG editors, but they're just too advanced and don't always function how I'd like them to.

I'm looking for something simple, but flexible; something that works in virtually any browser.

Text Returned From DB Gets Cutoff When Placed In A Text Field
I have a string that contains an apostrophe or a quotation mark, stored in a DB. I can retrieve the data, and display it properly (for editing) in a textarea, but when I try to put the string in a text field, it get's cut off right before the questionable character.

For example:
$string_in_database = "John's car."

 -displays correctly here <textarea><?php print $string_in_database ?></textarea> and displays this - John's car.

 -gets cutoff here <input type='text' value=''<?php print $string_in_database ?>' /> and displays this -  John

I've tried adding slashes and stripping slashes and I just can't figure out what I need to do.

Validate Text Field
This is very simple in javascript but I can't seem to find the exact solution in php. I have searched the forum but couldn't find my exact example.

I have "page1.php" with a <form> that includes one text field and a submit button. Once submitted the data in the text field would be entered into the DB. I want to make sure that before the <form> is submitted that there has been some data entered into the text field. I have seen the function --- empty() and I have also seen if (!$textfieldName)
all coupled with <? PHP_SELF ?> in the action field of the <form> but it just doesn't seem to work for me.

I think that it doesn't work because the page that I am entering data in the text field is also inserting data to the DB from a previous page and the <? PHP_SELF ?> is conflicting with this----(Just speculating).....I don't know I am kinda stumped.

Text Field Variable
I'm new trying to use php forms.  Trying to write what is typed into the text field to a file.  But its not working.  It makes the file, but the text field data is not written. Code:

Mysql Text Field
I have a DB with a column that is set as Text format. The data stored in the field will be stored in many lines. When I get the data from the DB I want it to display where the line breaks are I'm not sure how to write the script to do this. I have worked withe explode before but there is nothing come at the end of each line to do this with.

How To Query In A Text Field
can i query in a text field, i have the normal fulltext search but i want to or substr search it or something, but i dont know how.

GD Library - Underline
Using GD library how to make the text underline.

I have used imagettftext ( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text ) this function for write text to the image. I could not make underline text on image.

How Do I Get Rid Of The Underline On This Ticker
im using the following ticker which used to have an a link on it but i want to remove it, therefore i have just changed the location to #.

However, I want to remove the link altogether. I tried removing var theSiteLinks = new Array(); and  print('theSiteLinks['.$i.'] = "'.htmlentities('#').'";'."
"); but then the ticker wouldnt work.

any suggestions? Code:

Validating TEXT Field Entires
Because I have several TEXT fields in my MySQL database, I need to know how to validate that only alphanumeric characters have been entered -- as this data will be echoed back to the user upon completion of the form.

Therefore, I need to prevent any malicious text from being entered into the form (SSIs, HTML formatting, etc.)

Is there any way to do this?

So far, I've only been referred to addslashes(). I've managed to use the following function:

function validate_text($text) {
$text = addslashes($text);
return ($text); }
$input_text = validate_text($input text);

But this only escapes single and double quotes with the slash. URLs, SSI statements, etc. remain untouched.

TEXT Or BLOB Field Problems
When I use a form and php to input long articles (in a TEXT field) into a mysql table, the code runs smoothly (i get a thank you message). However, the record isnt always put into the table.

If I input only the varchar fields into the form, then it works. But if I also try to append the TEXT field then it doesn't work from a web form. It works sometimes but not all fo the time.

Why does this only work sometimes, do i have to do something witht he code? change the database?

Form Text Field Validation
I've got a form and I'm now trying to validate the text fields in it. The field I want to validate is for someones name, so there should only contain letters. Below is the function I've written to handle this. Code:

How To Find A Match In A Text Field ?
i am using ereg($rowvalue[0],'humor2')==true to find a match in the text field. how can i find a exact match, ie. the text field contains 'humor,humor2'

so, if using ereg the result will be true for both humor and humor2 but only 1 - humor2 is correct. how do i find an exact match ?

Increment A Text Field In A Form
I am creating an intranet which shows active projects and allows people to add new projects. If users want to add a new project, they fill in a form but what I want the form to display in the ProjectNumber field (which is a var char field & not the primarykey) is the last Job Number incremented by 1.

For example if the last ProjectNumber was TS0014, then the default value in the ProjectNumber field should be TS0015 - this way users know what the next job number is.
At present, the last job number in my table is TS0014. Below is the code i'm using but for some reason in the Job Number field in the form Im getting TS001? WHY? Code:

Text Field As Date (MySQL)
I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Form Field Text Output
How can I get html code in an editable form field to display properly? Specifically: I have text that is echoed to a form field via <? echo $text ?>

The user can then edit that text and submit. However <BR> is showing up as a literal <BR> and should be a linefeed. Is there a way to have this display properly?

Example: LINE ONE<BR>LINE TWO
should display as
LINE ONE
LINE TWO

Note that this is only a problem in the form field. It displays properly when echoed outside of the form.

How To Get Un-escaped Text From A Form Field
I have a php script that gets the text from a form field:

<?php

include("global.inc.php");

pt_register( 'POST', 'test1');
echo $test1;

?>

The text comes back fine, just some characters (', " and ) are now escaped
(', " and ). The problem is that I need the he text to be exactly as it
was entered by the user. I could process the text myself, and replace the
escaped characters, but I'd like first to understand why this is happening
and if there is a way to disable this behavior and get the unmodified text
directly.

Text Field, Dates And Insert
The user types a date (dd-mm-YYYY) in to a text field, the date is checked against a regex and if it passes, is then inserted to a database.

For some reason inserting the date ($this->input->post('date')) directly in to the database gives the default for the field (0000-00-00). I've tried doing date("d-m-Y", $this->input->post('date')) but get 1970-01-01 or something like that. Do you have any advise for converting the text field input in to a format that can be inserted in to the database?

Removing URL Link From Text Field
How can i remove a URL link from a form text field or the area where results are posted when a user enters http://www.mywhateversite.com. For example, here on this site.

I want to allow the text, but not the link. If you guys are familiar with myspace and have tried to put a link to another site, the myspace site automatically changes it to something else or blank. Thus allowing the user to post the site url, but without the link.

How Do I Underline My Search Results?
This is a PHP/MySQL question.

I have a search engine that finds matches of a word in artist names, and their album titles. How do I underline the word that is matched when I display the results? I've seen this on Yahoo! and was wondering how to do it.

PHP Will Not Read More Than 4096 From My Microsoft Sql Text Field.
I have a textarea that is saving to a mssql text (very large) field. The insert, update is working fine. However, when php reads the data using mssql_result function, I'm getting limited to 4096 characters read by php. I know that there are at least 6000 characters and I can see them using microsoft's query analyzer. This is not a magic quotes, single quote, quote, html entity or anthing like that. PHP will not read more than 4096 from my microsoft sql text field. Any ideas how I can get php to read more?

Is It Possible To Modify Part Of A Text Field Output?
I am made a simple web site search function. I use MySql 4 and have a table that contains all text on a web site in a column type text.

I can search it, but I want to make the search term bold when I print out the text field content. PHP Code:

Text Field Eats Up Multiple Words!!??
I pass a variable in my url which is let's say two words separated by a space.
now if i just echo($variable) then i get both the words as they are.. separated by a space... but on the other hand if i put that same variable inside a text field.. i.e <input type=text name=bla value=$variable> i get only the first word of the variable

e.g.
$variable = "hello there";

displayed normaly i get:
hello there

displayed inside a text field i get:
hello

i tried using different things like urldecode/urlencode/rawurl blabla/ the best i could get to display was a hello+there
so is there any solution to displaying $variable as it is inside a text field.. by the way it displayed fine if i use a textarea but i need to use a normal text type input.

Inserting A Row Of Characters In Text Field Automatically
Good Day to All! Hoping someone can help with this simple problem. I am inserting text into a text field. Because there may be a number of entries made sequentially I want to automatically insert a line of characters such as ****** or ------------- automatically between rows to make the output more legible. Here is what I have so far. I want to insert the line after ....

How To Sort A Flat Text File By A Particular Field
I have created a flat file database to store contact information on my friends. The fields are 'firstname', 'surname', 'job title', 'address' etc What I am trying to do is be able to display a sorted list of my friends based on a particular field eg 'sort by surname'or 'sort by address' etc

Each row in the file ends with a '' and each field in each row is separated by a ' '.

I have come to the conclusion that I need to use the array_multisort function but cannot find any examples of taking information from a flatfile database and using array_multisort to sort and display based on a particular field. This is how far I have got but I am now stuck as to where to go from here? I have read the php manuals but it does not appear to improve my understanding of what needs to be done. Code:

Displaying Information From A Database In A Text Field,
I am trying to create an admin page, but before I get anywhere near that, I need to understand how to get data froma database to show up in appropriate form fields *text, textarea, etc...*

I am able to get content from my database to show up in my template, now I want to create a page that allows a user to click on a link for which they want to edit the information (name, and bio) So I want that page to show up with a simple form, a text field displaying the name, and a textarea displaying the bio information, so that they can modify it and save it to the database. how do you get the information to show up in the form fields? Code:

Displaying First 50 Characters Of A Mysql Text Field?
I have been searching for hours on the php website for a function that
will allow me to display just the first 50 chars of a mysql text field
in a results table, but i'm having no luck. I need it to create a
results page for a site i'm creating in php.


Passing PHP Variable Into An Html Text Field
I am working on a flatfile configuration program and I need to read a single record csv file into php and pre-load the values into html text boxes. I have the file reading part working with 6 variables $field1 through $field6. When I am done, I then save the form back to the same file. This allows a configuration file to be updated from the web.

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.

How To Check For Blank Spaces In A Text Field???
does anybody know how to check for blank spaces?  I dont just mean blank, blank but actual spacebar spaces. ive tried is_null and !isset and neither one works??

Error When Inserting A ' Into Mysql Text Field
I'm using the below code to insert some text fields from a form into a database. I've noticed that if we type something using a ' (i.e we're all going out for the day) in the text field then we get a insert error back from mysql saying it can't insert into the text field. I kind of think I know what the problrem is but need someone in the know to clear it up for me ....

Help On A Multiple Keyword Search On A TEXT Field Type
Working on a php/mysql driven site which requires me to have a search facility based on multiple keywords. I read the tutorial "quick and dirty search engine". What i want to know is :

1. Is there any SQL query i could perform which could to almost the same thing ( i dont really need the accuracy ) ?

2. Any other methods of achieving it?

Book Script ,should I Use Txt File Or Mysql Text Field ?
I am doing simply book script, where we will have hundred of books,user will be able to read chapter by chapter or search etc.. As u know that book contain will have html tages..etc.. and each book is around 200 kB....My php script read text file and display. It's a huge text file.

I am thinking to use database instead of text file. But text files are very huge. My question, should i use database instead of text file ? which one is faster and better.

I have noticed, when i copy 150 kB files and paste into phpmyadin, it gives me internel error..but it insert record. I used txt field for book contain.

Is There A Php Command To Take A Specific Field From A Delimited Line Of Text?
I have a string which is multiple fields delimited by commas.

I would like a php command that says... take the 3rd field for
example.

ie. If MYVARIABLE has the data "hello,there,big,world".

I would like to be able to say, pickup the 3rd field "big" without
knowing the character positions or lengths.

Removing/stripping Unwanted String In A Text Field
I have an abstract field that contains some rtf codes..now I want to strip all those rtf format so I can display it in my page cleanly..how can I accomplish this?. Code:

Formatting The Contents Of A Text Area Form Field
On my site I get users to enter a load of information in a textarea
box, however when i save this data to my mysql DB and then retrieve it,
it comes out without all the formatting, like new paragraphs and new
lines.

Can anyone tell me how you can capture the data entered into such a
field with all the formatting the user has entered like new paragraphs
etc?

Disable Submit Button If Text Field Is Empty
I am unsure if this must be done with Ajax, or if it can be done with PHP. I have a simple search page where I want the submit button to be disabled if there is nothing entered in the text field, and once something IS entered, then the search button is enabled.

I was thinking Ajax, because I am looking for it to be real time and I am not sure if its possible with PHP as I am just a novice when it comes to certain things. So the button is always disabled when there is nothing, and enabled when the user enters something.

And lets say the user enters something and removes it, then the button disables again? Is this possible to do with PHP and if so, could someone please help me tackle this . Code:

Need To Insert A Bold Tag
I need to enter a bold tag on a part of my db. This is the only place where I can enter:

$actcp->number = "some text here <b>" . $actcp->number ;
} else {

Any ideas on how to enter the closing bold tag? I am getting a blank page when I enter it normally. I tried adding the ." or just ", but no luck.

Clearing The Input Text Field After Submiting The Form To A New Page
I have a page with a form with an input text field ... and when a user types his/hers ID ... and submits the form - his/hers page opens in a NEW window .... but the value (ID) that was written in the original window remains.

I want to make sure that the form input field on the original page becomes "invisible" - by refreshing/reloading the original page or just by clearing the input form after submission.

For now I have put in a meta refresh tag in the head of the html file ... but that is not the solution ... becouse I only need a one time refresh/reload of the page ... and this is to happen right after the input text value is being submitted.

How To Display First Record In Bold
I'm pulling news titles from MySQL. How Can I display first record in
bold (different than other ones). What is the best way to do that. Is
there some 'magic' query or PHP function.

*First Headline*
Second Headline
Third Headline

Need An Asterisk In Error Message To Be In Bold
Hi all, Just trying to make the asterisk appear
bold, but it's not happening ;-( Could anyone
please have a quick look at the code below and let
me know if it should please?

Any help appreciated.

Make Today's Date Bold?
I'm currentlty studying on zend's calendar tutorials. How do I get today's date to be in bold? PHP Code:

Bold String From Array Of Keywords
Here is my code:

<?php
function boldText($string, $array){
$string = strip_tags($string);
return preg_replace('~('.implode('|', $array).'[a-zA-Z]{0,45})(?![^<]*[>])~is',
'<strong>$0</strong>', $string );}?>

This will bold all words that contain any word in the array, so if the string is my superman cat and I search for super I would like the word super to be bold in superman so, when the results come back from my search, I would like it to display like this: my superman cat.

Highlight/bold Largest Number In A Column
i have my database setup to show weights of the item. How can i tell my php script to highlight the cell in the table or bold the weight in the table?  i hope what im trying to say makes sense.

instead of sorting it by the heaviest weight i just want to be able to highlight/or bold the heaviest weight so the names of the items stay in alphabetical order. and i will be able to tell which item is heavier.

Can A Field Communicate To A Server And Return Information To Another Field Without Retrieving The Whole Html Code Again?
I´ve got a sql table which has 3 fields.
Their relation to each other is like this example.

| CARS | YEAR | PRICE |
ford 2000
ford 2001
ford 2003
volkswagen 1999
volkswagen 2000

I am developing an ASP web page that modifies a specific registry.
So, it loads the information to some fields, but the user will be able
to change only the "PRICE" field.
I have to create two selects, one for "CARS" and other for "YEAR".
But the "YEAR" field will only contain the correspondent years for each
car the user selects. Example: selecting "ford" in the "CARS" <select>
box, only the years "2000", "2001", "2003" would be automatically
loaded in the "YEAR" <selec> box.
How could i implement it?


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