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




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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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).

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.

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?

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.


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 ....

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.

Reading MySQL Data In A Form Field
i am in the process of building an admin page for a site. Most of my site data is being held in MySQL and being pulled using PHP. The problem I have is while trying to build an Admin form to change data in MySQL, I want to have the data that is currently in the table be automatically put into the form field, so they can see what they are changing before they change it, or so if they do nothing it keeps the same data in it. My code is as follows:

Display Mysql-data In Flash
How can I display mysql-data in flash?

Mysql Data To A Text Box
I am trying to retrieve a text block from a Mysql database and display it inside of a <textarea> how do i do this?

MySQL 5.0, FULL-TEXT Indexing And Search Arabic Data, Unicode
MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode

[This version has a couple subtle edits from the orginial I posted
on mailing.database.myodbc - I'm cross posting here on this
topic/subject related newsgroup]

I was wondering if anybody has experienced the same issues
challenges I'm experiencing I'll describe shortly. Once
resolved some fascinating and powerful multi-lingual
apps incorporating non-English/latin character sets can be
realized by many developers.

I have a Unicode utf8 English - Arabic - Hebrew - Greek (and
several other languages) database in Microsoft Excel. I KNOW
that it is Unicode utf8 data because MySQL tells me it
recognizes the encoding as such but not in the context I want.

Allow me to explain ...

I can search the Unicode utf8 encoding with no problem in
Excel. While in Excel I highlight a complete word or a
partial string of an Arabic word copy it to the clipboard
(i.e. memory). I then do a find and the process is the
same successful result as if it was an English string.

MySQL 5.0 is supposed to handle Unicode utf8

I created a MySQL database I named: languages

CREATE DATABASE languages ;

and I implemented the following command on a MySQL
command prompt:

ALTER DATABASE languages DEFAULT CHARACTER SET utf8;

No problem (so far) MySQL seemingly recognized utf8 and
accepted it. My understanding is with the ALTER command
the tables I create against languages will be utf8.

I now created a table I named mainlang which denotes it
will be the main table for my languages.

mysql>CREATE TABLE mainlang
->(
->langNumID varchar(30),
->colB varchar(30),
->colC varchar(30),
->primary key (langNumID, colB)
->);

Again so far no problem: Table successfully created.
My third column 'colC' is where the Unicode data
will be stored.

I now attempt to import the database from my
Excel file into my MySQL database as follows:

mysql>load data infile 'c:arabicdictionary.csv'
->into table mainlang
->fields terminated by ','
->lines terminated by '
'
->(langNumID, colB, colC);
ERROR 1406 (22001): Data too long for 'colC' at row 1

So what to do? I did a search and found other
people seemingly had the same problem and someone
suggested:

ALTER DATABASE languages DEFAULT CHARACTER SET cp1250;

I dropped mainlang, recreated it, redid the load and
Lo and behold ... it seemed to work. No Data too long
error occurred and when I did the following query:

mysql>select langNumID, colB, colC
->from mainlang
->where colB = &#55617;&#57074;'

I see colA have a correct numeric value, colB a
correct numeric value (4994) and for colC a string of
unintelligible characters with diacritical marks,
oomlats etc. which I know is the cp1250 encoding
interpretation of the Unicode utf8 data which is
similarly unintelligible in its own regard.

Now what I try is: do a copy of the obscure colC
cp1250 character string into the clipboard/memory
and then do the following tweak on the original
select statement to see if I can search on the
(now) cp1250 character string:

mysql>select langNumID, colB, colC
->from mainlang
->where colc = 'paste of the cp1250 character string'

The computer would not allow a paste unless I pressed
the escape key. On initiating this select command
I got an empty set (no match)

My questions are:

Has anyone been successful creating a Unicode utf8
MySQL database that accepts Arabic?

If yes, how did you get around or not encounter the
Data too long issue?

Have you tried the cp1250 (or cp1251 - same mechanics
same results) work around as I have? Are you
able to search the cp1250 character string (my colC)?
If yes, how did you successfully manage to do it?

Lastly, if I take the cp1250 encoded string and paste
it into Excel ... I can string search the cp1250
encoding with no problem.

Also, here's how I know my Unicode utf-8 data is
correct apart from my own manual cross-referencing
and being recognized by MySQL in some respect:

When I copy the Unicode utf8 encoding and try to
paste it into the select command to see what would
happen I get the following error:

ERROR 1257 (HY000): Illegal mix of collations
(cp1250_general_ci, IMPLICIT) and
(utf8_general_ci, COERCIBLE) for operation '='

So what I have here is a situation where MySQL
is recognizing Unicode utf8 encoding but not
from the respect of packing a table!

Go Figure ...

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 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.

Display Only Field...
how can change this field, a text box, to a display only(non-editable field) in php?

                        <td width="196" height="22"> <div align="right"><font class="inputLbl">Date:&nbsp;&nbsp;</font></div></td>
                        <td width="130"> <input name="datebox" class="txtbox" value="<?

is it possible to make datebox a display only field? i dont want users to be able to enter invalid dates here. they should only be able to enter date from the datebox feature(a calendar pop-up). that feature works with all validations in place. its only when users enter (manually type) a date in the text box that valiations dont work(for instance, 05/32/2007 is taken as a valid date!)

i want to change the datebox field to a display only field.

Display Large Field Value
I need to know how to display large field value in a small place for example: the word "Red Agate Silver Bracelet" appear like this "Red Agate Sil..." and in the hint display the full length Note: I get the value from a database.

Display Image If Field =
how can I display an image if a field for a user shows a 1

DATETIME Field - I'd Like To Display As A 'DD-MM-YYCC'
I have a datetime field with this format 'CCYY-MM-DD
hh:mm:ss'. I'd like to display as a 'DD-MM-YYCC'.

How Display All The Record Of A Certain Field In A Combobox
How can I display all the record of a certain field in a combobox after I
have connected to a db in mysql ?

Table Display Grouped By Specific Field
I operate a youth sports website and i display my current alignments in a long running list of teams (one field within my table) with association divisions (another field within table).

I would like to group them by divisions, like a two column table for better clarification.

Display Specifc Field From Explode String
I am trying to display a single field from an explode string. I have no idea how to do this. The script already explodes the string and loops the data displaying it in table format. Code:

Limit A Database Field To Displaying Only One Time And Still Display All?
I have a data table with a field that contains the exact same text (example "some text") on several different rows. How can I display all my rows without getting duplicates of this field; I only want to display this field once. I tried to use a LIMIT, but this is not what I needed. Code:

Select Both Field Name And Field Value- Mysql ?
What function to use to select both field name and field value from a mysql table ?

Problems With Reading Data From A Text File And Inserting The Data Into DB
Ive been having problems getting this to work for 3 days now. Basically what im trying to do is read from a text file and insert the information into mysql. The text file is in this format:

"LuCyndi@infiniti.com","carol","kellerhals","109 veeder dr","las vegas","NV","89128","702-254-2061","45"
"the_prophet@att.net","a.","cohen","6794 e. bonanza rd","las vegas","NV","89110","702-463-6569","55"

I understand how to open files to read but im having problems turning each set of data into an array so i may insert it into mysql. If someone could please help it would be appreciated.

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:

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.

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:

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.

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:

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.

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??

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..

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.

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?

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:


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