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




Explode Text Area Into Array For MySQL Table


On my site, I have a textarea where users enter their sites' information in the following format (tab-delimited):

Site Name <tab> Site Description <tab> URL <newline>
Site Name <tab> Site Description <tab> URL <newline>
(and so on...)

I know I have to use the "Explode function and a loop to get the data into an array and enter it into a MySQL table. Would anyone have a snippet of code off-hand that could show me how to do this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Text Area Not Accepting Large Amounts Of Text
I have a form where teachers enter homework assignments and they are then stored in a MYSQL database and retrieved elsewhere.

I have been using "get" with the form. The code is simple:

<textarea name="array[assignment]" cols="60" rows="10" id="array[assignment]"></textarea>

It does allow post of 100 words, etc. Stuff that teachers normally submit.

What's happening is that it won't allow very large posts (over 300 words maybe? ) Not sure what the cut off is. When you press submit it won't go, or there is an error where it won't submit.

Is there a limit for text fields? Since the fields scroll, I didn't think that having only 60 rows was any type of real limit, I though you could put in as much as needed. But then all of it ends up in the address bar, so there must be a limit of some sort.

Replacing Text For Use In A Text Area...
I have a PHP page that allows a user to preview an email and then send it
if(s)he is happy with it.

Otherwise, they can click on an edit button and edit the text of the
message. The text is then shown in a textarea element.

While in situation A (the preview), a bit of formatting is useful (e.g
<BR>), all of this formatting is a nuisance in the textarea.

Basically, I would like to do the following:
a. replace <BR> with a line break for the textarea
b. get rid of double spaces and tabs before the text is loaded in the
textarea
c. put the <BR>s back in when the user is finished with editing the message.

Is there a way to do this?

Text Area
I have a textarea that the user can put a paragraph of information in it. I am wondering. with my submit button. if there is a way to make the information of that textarea = to a variable. so then it can be used as text.

<textarea name="comments" cols="40" rows="5" value=value="
<?  ?>"</textarea></td><td></td></tr>
<tr><td colspan="2" align="right">

That is what i have for the text area.

Updating A Text Area
I'm writing a sort of mini chatroom. The problem I've run into is that I can't figure out a way of updateing the HTML textarea I am using to display the messages in the chatroom.

I want it to update about every 10 seconds or so. Is there any way of doing this in PHP? I'm willing to try JavaScript too, but I've only just started learning that?

Dynamic Text Area
how do I create a dynamic text area that whenever I select a value from a dropdown list it will automatically fill up the form of my html. the dropdown list contains dynamic values from mysql database. Whenever I click a value, it automatically fills up say for example the name, address, email, etc...

Text Area Input Box With PHP
I have a text area box on one page. PHP sets the information that is inputted into the text area into a variable. When I print this info to the screen via echo, it does't have the line retain the formatting that the user had in the text area. It has no line breaks, it runs everything together.

Bigger Text Area
Is it possible to get a bigger text area? So far I have: PHP Code:

Text Area Spacing...?
I have a form, and it's a text area. If I press enter twice, it makes a double space, but when I press submit, and it changes the page, it does not double space!. How can I make my code translate those "enter button" presses into a new line?

Just in case you need to know, it's writing whats inside the text box into a row in my MySQL Database. So in a way, you could say that when you press the "enter" button, the text area does not take it as a new line. Here is my code:

Hyperlink In Text Area
I have a basic CMS system and the client would like to insert some links in the text area. What would you recommend the best way to do this in a textarea box? There may be several hyperlinks in 1 textarea and some may have none at all.

I assume this would be some sort of javascript code or is there an easier way.

Sizing A Text Area Dynamically
I have several text areas I am putting information from MySQL into. Right now they are 50 characters wide, by 10 rows. I want the number of rows to dynamically size do that the text area is the same size as the length of the data in MySQL.

I've tried all the logic I can think of... taking strlen and dividing it by the width... works great until they use line feeds... if someone puts:

"Hello... thanks."

the character count divided by the width is off. Here is the code I am using: Code:

Keep This Text Area From Being Edited In This Form
I need the textarea so it can not be edited by the user..... how can I hide it and keep it so it can not be changed

<textarea name="body" id="body" cols="50" rows="15">'.$_CONFIG['MAIL_BODY'].'</textarea>

this text area has an email message for my inviter script but I dont want the user to be able to alter the body...

how can this be achieved? I manages to hide the subject by ussing type hidden

but I dont know how to do it with this text area.

Detecting Line Breaks In A Text Area?
This is really frustrating... I have a form in which there is a text area for people to post comments on the site. I'm hoping that people will take the time to fill out reasonable length responses which my spread over two or more paragraphs. My problem lies there; it might spread over two paragraphs...

I know I can use 'special character(s)' which the user can put in that I can then do a ereg_replace() to put the <p> or <br> tags in but I would prefer that they didn't have to... like for instance in this forum

I've tried to see whether there are any line breaks or something in the textarea when a carriage return has been made but I can't seem to pick anything up, has anybody managed to come up with a solution to this?

Filling A Text Area With Options From A Select Tag
I read a ACCESS db table and the values from one column i use to fill a select tag (all the code is in a php file inside a iFrame tag): Code:

Writing To Heredoc From Text Area Form
I can't seem to get heredoc to populate correctly with variables through
a form.

<textarea name="Template" rows="10" cols="80">Template Here</textarea>

Contents could be something like: I want to replace $myarray[0] and
another variable $myarray[1]

I call heredoc this way:

$hubarray = explode("
", $contents);
$template = $_POST['Template'];

foreach ($hubarray as $val) {
$hostarray = explode(",", $val);

$output = <<<EOT
$template
EOT;

I'm feeding it a file that has multiple rows separated by
as array 1
and within those rows are fields separated by "," for array 2. I'm
trying to iterate through the arrays and populate heredoc($template)
accordingly.

How To Make Text Area Recognize Hyperlinks?
I built a simple form where a user can enter and post news items to his
site (with PHP, into MySQL). He doesn't know much HTML.

Is there some way he can enter some simple text to declare something a
hyperlink, and have PHP recognize that that means "make this text into a
hyperlink"?

....so that instead of having to type this into the textarea:

<a href="http://www.somesite.com">somesite</a>

....he could type something more intuitive, like this:

<somesite.com>somesite</somesite.com>?

Problem In Handling Long Text In MYSQL Table
i am making a database driven website which is working fine.
My web page contains lot of text and it is very diffcult to upadate its content from the text_field of MQSQL table. As i have to read each line again and again to update it.

I have alloted parent_id to each category_id in my database table and thus retreving results from it...

I want to know what should i do to handle this long text ...such as if i am able to make a seperate text file for each of my html_body variable and somehow include that file to a webpage when i select a particular parent_id from my wepage.

Using Php To Move Rows From Text File Into Mysql Table
Can anyone point me in the right direction for the way to read a text file a
line at a time and separate the fields on that line and use them as data in
an INSERT to add a record to a mysql table. Then read the second line in
text file and repeat.

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?

Click Button And Adds To Text Area - Like SMF Bbcode
How can I make buttons to add some things to a text area, like the bbcode for SMF?

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.

Paste HTML Page Inside Text Area
i want to create a newsletter or emailer form sender. and that form has a text area. can be an ordinary text area or can also be tinymce.

i want to have the text area in such a way that an HTML page can be pasted in the text area (let say the html page is jobpost.html) and send it to the email address that i specified.

Fetching Array From MySQL Table
Some told me to better learn some basics of php and mysql, but i encountered a problem that i couldn't solve with all the tutorials out there. I tried the following code to fetch an array from a MySQL table named Gallery: PHP Code:

Inserting Array Into Mysql Table
Anyone know the best way to insert an array from a form into a mysql table. My array is validated from the form and then inserted into the db, only when I SELECT it, it merely saya 'array' in the field.

Multidimensional Array In To A MySQL Table
Trying to load an multidimensional array into a MySQL table with columns as
follows,

level1,level2,level3,illust,item,description,partN o,qua,price,remarks,weight
,size,mass

the array first line is $input[0][level1]Engine
the array secondline is $input[0][level2]Cylinder Head
etc..

A 'foreach' inside a 'foreach' echo of the array gives the following, which
is correct.

0, level1, Engine
0, level2, Cylinder Head
0, level3,
0, illust, 001.pdf
0, item, 1
0, description, Casting
0, partNo, 238356
0, qua, 1
0, price, 1,245.00
0, remarks, This is for the Z350 series
0, weight, 5
0, size, 5x5x5
0, mass, 37
1, level1, Engine
1, level2, Cylinder Head
1, level3,
1, illust, 001.pdf
1, item, 2
1, description, Valve, inlet
1, partNo, 452790
1, qua, 4
1, price, 5.46
1, remarks, This is for the Z350 series
1, weight, 5
1, size, 5x5x5
1, mass, 37
2, level1, Engine
2, level2, Cylinder Head
2, level3,
2, illust, 001.pdf
2, item, 3
2, description, Valve, exhaust
2, partNo, 345436
2, qua, 4
2, price, 5.99
2, remarks, This is for the Z350 series
2, weight, 5
2, size, 5x5x5
2, mass, 37

Sorting A Table Into An Array In Mysql
Can someone tell me how to sort a table using a while function. This is what i want to do. I have table that has 17 fields, the first two are id and date and the rest of date..but what i want to do is take the data and sort it by the date and put the rest of the data under that date.

example:
date
Data
date
Data
I asume the array will look like this

result[0][0]
result[0][1]
result[1][0]
result[1][1]

and so on .....

Explode Array
I have an array name, text=value, text=value, name, text=value, name,.... and I want to do something like:

for($n = 0; $n < count($a), $n++){ //where $a is the array
$b = explode ("=",$a[n]);
}

So that I get a new array $b looking like name,text,value, text,value.

Explode Into An Array?
I'm trying to do: explode some data into another array. I will have the code in a loop so that the data in all elements of $RowData gets split up.

I would like $ZoneCodes[0] to contain 4 elements, but I would like them to be in the next dimension. i.e. [0][0], [0][1],[0][2],[0][3] Code:

Explode Array
The following code checks to make sure the same song is not immediately requested. PHP Code:

Explode My Array
i have a loop which stores the values in the array $store...i am using the following script after storing the values in $store now if $store[0 or whatever]="john doe" i want the $link as "john_doe" i tried ereg_replace but that also dont seem to work..so please guide in either cases Code:

Using Explode, On An Array?
Our website has a spanish and english version, the data for both languages are pulled using an arrays of arrays. I have one file that contains all of the arrays, here is an example of one

$products = array{
"dirtbike"=>array("dirtbike_eng","dirtbike_sp"),
}
A session variable is set (0 for English, 1 for Spanish) and the appropiate translation is pulled out of the array based on that.

It works great, easy to update and change things on our site...but now we want to take the task of translating and updating the page out of the hands of our web designer (me) and let operations do it.  They want a simple text file that they can edit and just upload to the web server for the changes to take effect...here is an example of what I have given them (translation.txt)

ID ------ English ----- Spanish
dirtbike | dirtbike_eng | dirtbike_sp

I can read the translation.txt file fine using $data=file(translation.txt);
Now it puts each line into an array.   What I want to do, is use explode on each line (using a ' | ' delimiter) and output each line into it's own array of arrays. Code:

Comparing PHP Array From Checkbox To MySQL Table
My problem involves updating a MySQL table using checkbox input. I'm relatively new to both PHP and MySQL so I'm looking for a little direction on the smartest way to accomplish my goal.

When a user goes to a project page, they are able to categorize their project by area. The user checks a series of checkboxes and the results are stored in an arrays called $category_ids. I'll called the project id $project_id.

What I want to do is compare the array $category_ids to entries in a MySQL table for $project_id. Then I want to add the links that aren't already in the table and delete the ones that need to be deleted. The table has these fields:

projects_cat_link (table)
----------------------
category_id ¦ project_id (fields)

Does anyone have any tips on how to do this? I've gathered that maybe there's a way to get the MySQL data into a similarly formed array and then use functions like array_diff to compare. But then I'm not sure how to use the comparison in a MySQL query to add/edit/delete the links.

Check If Any Items In An Array (php) Is In A Table (mysql).
I want to check if any of the items in a PHP array exist in a MySQL
table. What is the best way to do this with making repeated calls to the
database for each item?

Actual application is:

I have an array (in PHP) of serial numbers of units about to be
shipped.I want to check the ship record (a table in a MySQL database) to check
if that serial number has been used before.

According to our quality policy we never reuse serial numbers, serial
numbers are unique. So prior to printing the packing slip I want to
warn the shipping guy/gal a serial number may be incorrect.

I could brute force it and increment through the "to be shipped array"
and check each item against the table. But that is, as I said brute
force, and I am having to be concerned with system speed lately.

How To Explode Array From File?
contents of myfile.txt = 5035|9638742|11938 // (one line of text)

$myfile = "/home/path/public_html/myfile.txt";
$totals = file($myfile);
$var = explode("|", $totals[0]);
$i = number_format($var[0]);
$k = number_format($var[1]);

For some reason this is acting funny. I am getting a null value for $k for some
reason...

Is there a better way to do this?

Putting An Array In A Mysql Database Table Field
I want to insert an array into my database but i've got a problem with it.

Before i insert the array into the dbase i check if everything is in the array with print_r($array). Everything that should be in the array is in there so i insert it into the dbase.

When i check my dbase with phpmyadmin the field that should contain my array has the word array in it so i assume the array is in the dbase. But when i retrieve the data from my dbase and check my array with print_r i get the following error: Warning: Argument to array_values() should be an array in.

How To Get The Number Of Values In An Array After I Use Explode
I have the following variable which has three areacodes in it:

$areacode = "305,954,786"

$array = explode(",", $areacode);

after i explode $areacode, How to get the info. how many areacodes are there in($areacode). in the above example it is 3 area codes (305, 954, 786)

$array[0] equals 305
$array[1] equals 954
$array[2] equals 786

Protected Area/admin Area
I am building a web site and have included an admin area where I want to use a username and password that only myself and the admin will be able to use. I am using the following code, but something is wrong when I put it on my host: Code:

Explode Mysql Cell Value
is there a way to explode a cell value within a mysql statement for example:

("SELECT * FROM image_files WHERE details = 'Explode("-",details')Return array[2]'")

hope that kinda makes sense. I want to explode the value in column details at the "-" and get the third value sent in the array as it would if using the php explode feature.

How Can I Find A Name From One Table In A Text From Another Table?
I have one table with a description field and other info, and I also have another table with a list of names and picture url:s. When I display the text description on my site I'd like to know if there are a match with a name from the 'names' table in the text. Code:

Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?

Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for.  Can anyone help me get the Agreed? table's background color to the colors above? Code:

Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias'
the mysql_fetch_field function returns a value $result=>table which
will contain the alias, not the actual table name.
Is there a way to get the actual table name ?

I am running mysql 4.1 and php 4.4

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

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

Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example.

If the user inputs...

Milan in history

MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes.

What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script.

This request is about searching for the code or any code related to the questions involved.

Create A Table Regarding A Text File
I have this .txt file :

Roger|tow25$rank259
Isabelle|tow36$rank24
Pascal|tow12$rank29
Sergeï|tow45$rank5
Michel|tow1245$rank45478
Frédéric|tow1$rank125425

And this programm php3
<?php
$fichier = "classeur.txt";
if($fp = fopen($fichier,"r")){
$ligne=1;
echo "<table border=1 bordercolor="#00CCFF" width=500>
";
echo "<tr align=center><td colspan=3>TITRE</td>";
while (!feof($fp)) {
list( $name, $tampon ) = explode( "|tow", $fp );
list( $tow, $obj ) = explode ( "$rank", $tampon );
echo " <tr>";
echo "<td
align=center><b>Nom".$name."</b></td><td>Tow".$tow."</td><td>Obj".$obj."</td[color=blue]
>";[/color]
echo "</tr>
";
$ligne++;
echo "</table>
";
echo "$cell";
fclose($fp);
}else{
echo "Error : open impossible ".$fichier;
exit();
}
?>

I would like to past each value of the lines in the tex file, in 3 variables
$nom; $tow; $obj
and create a table with 3 column ( column 1 the name, in 2 the tow, and in 3
the obj)

Populating Table With Text File
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff



How To Make Text Wrap In Table Cells?
I don't understand this at all. I have a table with fixed width and height in pixels. Yet when I place a long text string in a cell, the cell expands as far as needed to the right or left to fit the string on one line. This is driving me quite mad. How do I ensure that a long string is displayed in a neat, orderly fashion? My question has nothing to go with wrapping text around images. I just simply need to have text wrapped!

How To Populate HTML Table From Local Text File.
I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
21/03/2005-20:04:51 XX,XX X,X 75 3,72

The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

Creating Temporary Table From Full-text Query
i'm using a full-text search on my db which works fine, but now i'm working on filtering the results further, like products in range of prices. my logic is to simply SELECT them out of the temporary table, only if it would be created. i don't think i need to paste any code since i think you get the idea.


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