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




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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Move Table (mysql)
how can i move a table from a database to another?

Duplicating MySQL Table Rows
I'm not sure whether this should be posted here on in databases, but it's a question about inserting records in a MySQL table using PHP.

I have a large table with some 50+ fields with an auto-increment primary key field. When a record is edited by a user, we need to duplicate the original record, and update the fields changed by the user.

My question is, what is the easiest way to capture and duplicate the original table row? Yes, I could read the record in and then loop through the $row[] array using this as the source of all fields (except the primary key), but it strikes me that there must be a simpler method.

Navigation Through Mysql Table Rows.
I am running a query on a master detail page which results in a number of records. I call this page the master detail page. The master detail page has a number of records listed as thumbnails. Each thumbnail has a link identifier which is linked to a detail page. On the detail page I have no problem querying the specific recordset through $HTTP_GET_VARS['id'] and the additional info below. PHP Code:

How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out.

What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:

Updating Multiple Rows In A Table In Mysql
ok so im making this form that updates multiple rows in the mysql database but the thing is that the number of rows is a variable so once it may be one row once it may be 31 rows. is there anyway i can do this using a while loop? or even is there a way to do this period?

Deleting Rows On Text File
I have a function where it writes data on a text file with an assigned id. For example, the text file looks like:

data.txt

1|Hey
45|Hi
76|Hello

What I'd like to do is add a function that will allow me to use the specific line that start with the id. For example:

delete.php : On this file I will pass the id number and based on it, the function will go to the data.txt file and delete the specific row. So if I pass the id=45, it will remove that row ONLY and the data.txt file will look like below after removal:

1|Hey
76|Hello

Divide Mysql Results Into Rows In An Html Table
I need to divide my mySQL results into rows with 4 results on each row. Its for a small image gallery script, I wanna show 4 thumbnails per row. I have all the code ready to get the info and show it, I just need an example of how I can take the data from the table and have it automatically go to a new row every 4 entries.

Copy/move Values From One Table Into Another?
I have some data in table, and I want to move that data (certain fields only) into another table in the same DB. I'm wondering how can this be done?

Move Table Row To A New Table
I have a database of some information and it is in a table row by row.

I have a page that displays these in a table row by row, however I want to have a link to the side of each row allowing me to transfer that row to a new table.

How would I do this? I've tried a few ways but that was a random guess and didn't work.

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

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.

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?

Move File Path?
I'm trying to move some files on my server but I cannot get the path
right. I've messed with this and can't get it right. Is there a way
to debug the path of a file on the server? Here is what I'm trying to
do. I have a upload.php file in root/beta/upload/upload.php and want
to move a file in the root to root/beta/files but I get error below.
What am I missing?

$file = 'After.jpg'
$newfile = '/beta/files/TestMe.jpg'

if (!copy($file, $newfile)) {
print "failed to copy $file...
";
}

Warning: copy(After.jpg): failed to open stream: No such file or
directory in
/hsphere/local/home/barkster/zipyard.com/beta/ThinUpload/TestUpload.php
on line 5

Move & Rename File Keeping Same Ext
I'm trying to move a file and rename it at the same time put keep its extension. PHP Code:

Move Uploaded File Problem
I'm using move_uploaded_file function to upload images. it can work properly for gif, jpg, png and etc format. but it appear to have problem when upload bitmap images. the bitmap image cannot be uploaded.. why this happen?

How Many Rows In A Table
I am sure there must be an easy way to determine the number of
rows in a table, but I can't find it.

New Table Rows
I retrieve 20 items from a MySQL database. I want to display the output in a table. How can I display 5 items on a table row and then begin an new row?

Mysql Table Vs Log File
I have been doing some searching for  a tutorial on creating a simple tracking script to attach to each of my pages.  The tutorials that I found are using a log.txt file instead of a mysql database.  can anyone explain why not use a mysql database

Eliminate Gap Between Table Rows?
I made my first PHP page that uses includes.
http://php.didah.com/main.php
But I can't get rid of a gap (about 5 pixels) between the table rows.

The content of each include file is one line like this:
<img src="images/nav.gif" width="100" height="600" hspace="0"
vspace="0" border="0">
No head or body tags. Just a 100 x 600 gif image.

Here's the code for the main.php page:

<html>
<head>
<title>First Include Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="600px" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td colspan="2"><?php include 'header.php' ?>
</td>
</tr>
<tr>
<td><?php include 'nav.php' ?></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>This is the content area.</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><?php include 'footer.php' ?></td>
</tr>
</table>
</body>
</html>

If you look at the main page in IE there is a vertical gap between the
header, nav, and footer image. Does anyone know how to get rid of this?

Selecting Rows From Db Table
In a project mentioned in another thread, I'm trying to get some
dynamic data to work. In this discography, you can click on an
album name, and the title of the album and its tracks will appear
on the left. I have the beginnings worked out, like so:

***

<h3><?php echo $row_rsindiv['Album']; ?></h3>
<ol>
<?php do { ?>
<li><?php echo $row_rsindiv['Song']; ?> (<?php echo $row_rsindiv
['Time']; ?>)</li>
<?php } while ($row_rsindiv = mysql_fetch_assoc($rsindiv)); ?>
</ol>

***

A sample of the database:

***

Electronic Meditation 3 Cold Smoke 10:48
Electronic Meditation 4 Ashes to Ashes 3:58
Electronic Meditation 5 Resurrection 3:21
Alpha Centauri 6 Sunrise in the Third System 4:20
Alpha Centauri 7 Fly and Collision of Comas Sola 13:23
Alpha Centauri 8 Alpha Centauri 22:04
Zeit 9 Birth of Liquid Plejades 19:52
Zeit 10 Nebulous Dawn 17:47

***

I want to tell PHP to write the album name and list the tracks in
an <li></li> based on whatever album title is clicked in the main
table.

The main table looks like:

***

<?php do { ?>
<?php
$class = ($class == 'odd') ? 'even' : 'odd'
?>
<tr class="<?php echo $class ?>">
<td><?php echo $row_rstdream['Album']; ?></td>
<td><?php echo $row_rstdream['Year']; ?></td>
<td><?php echo $row_rstdream['Era']; ?></td>
<td><?php echo $row_rstdream['Type']; ?></td>
</tr>
<?php } while ($row_rstdream = mysql_fetch_assoc($rstdream)); ?>

***

I thought maybe of changing the first <td></td> to:

<td><a href="#" onclick="<?php $album = $row_rstdream['Album'] ?>">
<?php echo $row_rstdream['Album']; ?></td>

But that's as far as I can get with my limited knowledge. Does
anyone have any ideas on how to display only the rows in the second
database that correspond to the name of the album clicked on? Sorry
the examples are so long,

Copying Rows To Another Table
After I select a row whose ID is 10 or some other number, I need to
copy the entire row into another table.

Is there a way to copy rows between tables using PHP? Could someone
please point me to an example..

How Do You Find Out How Many Rows Are In A Table?
How can you tell(using php) how many rows are in a database table.

Create A Table In MySQL From A .php File
Is it possible to create a mySQL table from a .php file? If so how?

Help With Randoming Pulling Out Rows Of A Table
Suppose I'm connected to a database and I do the following:

$query = "Select q_id, question From questions Order by q_id";

$result = mysql_query($query);

Now, what is the best way to pull out 20 random rows from my questions
table?

I'm trying to set up on an online trivia page where different
questions are posted each time a person visits the page and I'm
pulling my list of questions out of a database.

I know mysql_fetch_array fetches one row at a time and array_rand can
pull elements out of an array at random, but I'm at a loss at how to
coordinate these two functions together to do what I want to do.

Selecting Random Rows In A Table.
How can i randomly select rows? say for example i have 50 users, 3 of them were online. I only want the 3 online, BUT i want then to be randomly choose. So that everytime i go to the page, it is a different person. Im assuming MySQL numrows has something to do with it but im not quite sure.

Downloading File Stored In Mysql Table Through Ssl
I have a table where I store some binary data. To retrieve this
information as a downloadable file, I use the following code:

header('Content-Type: $mimeType');
header("Content-length: $size");

// for filename, i store the filename in the table, so this does not
actually
// point to a physical file name on the file system
header("Content-Disposition: attachment; filename=$fileName");
header("Content-Description: PHP Generated Data");
echo $data;
return true;

If I go through a normal port (http), the file downloads no problem.
When I try this through ssl (https), I get the following error:

'Internet Explorer cannot download / from 192.168.0.9.'

Through port 80, the filename is set correctly. Through ssl, the
filename doesn't seem to be getting set. Is there a problem with
using 'Content-Disposition: attachment' through ssl?

Looped Rows In Table Add & Remember Values
I'm trying to get this app to work. It's supossed to:

1. create rows dynamically through a loop (done)
2. remember the user-entered-values while the form posts to itself
3. provide a total (addition) of all 4 rows. (kinda tricky since the rows are looped).
PHP Code:

Parse HTML Table Rows Into Array
I have a script that extracts an HTML table from a page into a text string. I would like to parse each row of the table into an array named "$rows". I would like to keep the html intact so that I could re-create the same table like: Code:

Adding Multiple Rows To Table Using Checkboxes
I'm looking to select using checkboxes certain rows from the results of 'table a' and add the selected rows to another table using checkboxes. I Have had limited success adapting some code for deleting multiple records using checkboxes. Code:

Dynamically Create Table Rows As Needed
I have a form with a table. Each table row has a ID= "some number". I have 4 rows and might need to create more. how can i do this in php? To go along with this, When I hit the submit buton, I then need all the table row data saved to a db i have. I can insert 1 line with out a issue. I also made sure the table row name="" fields are unique. ex. Code:

Displaying Multiple Queries To Same Table Excluding Different Rows!
i've got a table with 224 town listings and their ID's in it from 6 counties, and I want it to displayin a 6 columned table, each county getting their own column. Anyway, here's what I've got and what's happening: PHP Code:

ECHO The Amount Of Rows In My Table According To A Specific Username
I am creating an infinite loop with this code. My goal is to just ECHO the amount of rows in my table according to a specific Username. How do I do this? my code:

<?php $query = "SELECT ID FROM products WHERE Username = '{$Username}'"; 
$result = mysql_query($query) or die(mysql_error());
$row = mysql_num_rows($result) or die(mysql_error());
$num = 0;
while ($num <= $row) {
echo $row;}?>

Ordering & Limiting Multiple Table Rows By Date
My goal is to select rows from two tables 'shoot' & 'video' and have mysql order those tables by date and limit the number of rows returned. I want to list the latest 10 rows but am uncertain how many rows from each table will be the latest. I may have more recent shoots than videos or the opposite. How can I use a single ORDER BY and LIMIT statement for both selections? Code:

Export Mysql To Text File Via PHP
I need help on how to export one of table mysql to text file to download. (not saving text into server)
something with like header("Content-type: text/plain");

Importing Csv Text File Into MySQL
I have a CSV file delimited by ~. Here is an example of 3 records: Code:

Importing Text File Into MySQL DB
I'm writing a script to import a text file with fields delimited by ~ into a MySQL DB. I'm trying to import everything into an array first, so that one array row = one record row. Here is some dummy data, with the &#390170;' record having a couple of new lines where a new paragraph is. Note the other records have NULL in the same field: PHP Code:

Create A Button To Export A Mysql Table To An Excel File.
Does anyone have the code that creates a link, and on click, takes a specified table in my database and exports and downloads an excel file?

Code To Make Table Rows Of A Result Appear In Alternating Colours...
How can I get it so that when I run a search, and the results come back in table format, the rows are alternating colours, like on Devshed's forums? I believe there was some code here some time ago saying how to do it..

Reading From Text File And Storing In MySQL
I have a text file consist of 10 digit phone numbers one number per line like this:

5553332244
5553332244
5553332244
5553332244

etc…

How do I read a text file line by line and populate the data into an array to store it into a MySQL database? My database is below:

Read The Contents Of A Text File Into MySql Using PHP
New to this, have the basics, can build a form and such. My problem is I
need to be able to open a file on a pc/s on the network, read the data
character by character, check to see if a certain character is present, if
it is, update the database and continue reading the file until it comes
across the character again, updates the database and so on . . . .

Importing A Flat Pipe Delimited File Into A MySQL Data Table
I have done this in perl but eeew I don't want to use perl anymore. I
want to be able to take a flat file that looks like this:

mbriones@...|Marian|Briones
bobsmith@...|Bob|Smith
janedoe@...|Jane|Doe
(etc)

The table has more than 3 fields, so I'd want to process the flat file
and then do an INSERT into mailinglist SET field=$value for each line.

Does someone have a nice way for me to do this? The flat file will be
uploaded to the server via a form (copy) and then be processed.

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.

Uploading Info From A Text File Into A MySQL Database
what would the PHP and SQL code be to say basically: make a new row and put this in the field, what comes after each comma goes in a new field, and each new line should be a new row.

I have a huge text file that i don't have a way to upload directly into a MySQL database because my webhost isn't allowing it for some reason.

Site Stats, Php/mysql OR Flat Text File?
I'm have a cms  and I want site stats built in, thus apache's stats or cpanel etc don't cut it for multiple users.

I have a working stat query below, the problem is, in a short time 12 hours, it's grown to 109k with 500 records.
now I'm not adding a row for every person, I create a session, and if they already have a row, I update clicks (page clicks) as you can see.

still, it's big, the bots are eating it, so I figure, why not just create a separate table for bots, with 1 row per day and a click count. there, smaller. but with multiple users, and lots of normal hits, this will still grow quite large very fast!

so I'm wondering if flat text files would be a better solution? but perhaps opening and writing to a text file constantly gets very slow? I'm confused. Code:

MYSQL Query Script To Reading From A Text File
Im having a hard time converting the following tree menu script to read nodes from a text file, rather then a database.  This script works perfectly and is exactly what i am looking for, however it relies on query's from a MySQL database (I don't know how to set one up is the real problem).  I would like to keep the feature where you can pass a parameter through the script and its expands the corresponding folder. Code:

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?


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