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




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?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Include Text File From Local Computer
how do i "include(file.txt); if i have it stored on my computer for security reasons or do i have to upload it to my domain.

Dynamically Populate Drop-down List And Dynamically Include Html File
We have a drop down list on a PHP page, with several product names, and
when people click one item, we will refresh the same page with the
product name as parameter, and in turn we want to include a HTML file
into the content area of the same page.

I know it is recommended to put everything into database, but we want
the web site to be very "portable", so the drop-downlist and the
content should both in text files.

Let's say the drop-down list will be poplulated from the product.txt
file, and there will be a file for each corresponding item in the
drop-down list. From the user point of view, if he wants to add a new
product, he will just need to open the product.txt file, and add a new
line with the product name, "Laptop", then add a new text file named
"laptop" in the same folder which contains the HTML fragment to be
included in the content area.

What is the easiest way to do this?

Create & Populate Table?
I am trying to do two things with one form:

1. Create a table in a MySQL database
2. Populate it at the same time

So far I have been able to create it, but the population isn't going so well. Here is the basic code I am using. PHP Code:

Populate Oracle Table
Does anyone have a reference on how to do an insert with php into an oracle table.

Populate A Table That Is Already Created
I'm trying to run some script to populate a table that is already created. When I run the below code I am getting the completed message at the end, but my data is not going into my table....is there something incorrect with this code that is causing the issue? Code:

Populate A Dinamic Table With Two Different Querys.
i have a problem with a populate html table with data from table here
it's the problem

two querys retrieving data from table, one of querys show me a
colletion of data from 6:00 am to 15:30 pm timestampz, i put this on a
part of html table. when time on my if condition es great than 15:31,
showme data from 15:31 to 23:59 timestamp and populate another part of
html table.
but, data in html first part,it's gone away.
how can i put on html table data from two querys in same table?

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 Form From PHP/MySQL
I have found many examples of how to access an HTML text field from
PHP, but cannot find the reverse - how to load an HTML form from a
MySQL database.

Specifically, I have an HTML form which contains several text boxes
that correspond to the fields in a MySQL file. What I want to do is
call a PHP form that reads one record from MySQL and then populates
all of the HTML fields on the calling form.

The call to MySQL is not a problem - that works and I can use "Echo"
to verify that I have successfully read a record. Now, how do I get
that data back into the original HTML form?

Populate MySQL With Multiple Text Box Entries
I have about 300 rows of mysql data which I have chosen to diplay with a text box at the end of each row, that is available for adding comments. I would like to be able to add comments to entries and then have an update scripte that would take the text box, named "MC" and place the data in its row identified by a hidden field which would corrrespond to the Primary Key of the MySQL Database. I've done something similar using check box arrays, ie. Checkbox name="MC[]"

My question is whether I can write a script that would test for a value in the corresponding text box, and update the MySQL data accordingly. I have also provided in my display script that if the MC column is already populated in MySQL it will not display in the form.

Tab Delimited Txt File To Php Html Table
Wouldn't you know that when I finally find a tutorial using Google that does exactly what I want, the code doesn't run when I use it ...

However, when it gets to this line, for ($i=0; $i<td>$line[0]</td>, it chokes on one of the '>'.

Since my php skills are very basic, and in no way include arrays, can someone assist me with this?

If it's easier to do it differently, what I'd like to do is create a table in Excel/Access, export it to the server (to a tab-delimted text file, since I'll be using commas in my table cells), and have it display in an HTML table.

If I can't figure this out, I'm tempted to just export to HTML from one or the other program (not sure quite yet which I would use), so ...

How To Populate Data Into Text Fields On Page Load??
I am creating an account management page that shows the user's contact information and I would like to populate the textfields so that the user doesn't have to type in all his information when he wants to change something.  I want to have him type in only the information he wants to change or update. 

I already have the data displayed on the page. But now I would like to take the data and fill in the textfields with it.

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.

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

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

PHP4 : Extract Text From HTML File
I would like to extract the text in an HTML file
For the moment, I'm trying to get all text between <tdand </td>. I
used a regular expression because i don't know the "format between
<tdand </td>

It can be :
<tdtext1 </td>
or
<td>
text1
</td>
or anything else

eregi("<td(.*)>(.*)(</td>?)",$text,$regtext);

The problem is that, if I have
<tdtext</td>
<td>text2</td>

regtext will return text</td><td>text2.

How can I change the expression so that it stops at the first occurence
of </td>?


Populate A Database Via File?
How do I populate a database via txt or csv file, usign PHP? I want the person to choose the file to upload it in a website... and it will populate some table in the database choosen.

Parsing HTML Files On Local Computer
I would like to be able to open and read HTML files that are on my local (client) computer and then parse them to extract some specific information they contain.

I've been looking here and reading my PHP books, but it appears to me that PHP only opens files on the server or URLs. It think that makes sense to me. Is there an alternative?

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?

Save Html-forms Data To Local Disk?
A question on html-forms:

We have an application where users will get a CD with,
among other things, some html-forms for them to fill in.
When they click the submit-button, the data is transferred
to a webserver php-script that will then process the info.
The forms-definition looks something like this:

<form action="http://www.ourdomain.com/receiver.php" method="post">
<p>Question 1:
<p><textarea name="reply01" cols="40" rows="5"></textarea>
<p>Question 2:
<p><textarea name="reply02" cols="40" rows="5"></textarea>
<p>Question 3:
<p><textarea name="reply03" cols="40" rows="5"></textarea>
... etc ...
<p><input type="submit" value="Submit answers!">
</form>

Now, my concern is (since there might be quite a lot of data filled in),
if e.g. the internet-connection for some reason is broken
at the moment when the user clicks the submit-button,
there is a risk they will lose all the text and would have to re-type it,
which I would like to avoid, of course.

How can I best solve this issue?

Ideally, I would like to store the info on their local C: drive
before submitting, and automatically retrieve the text if they
later return to the page, but I guess that's not possible from
an html doc, right?

If so, any other suggestions how to resolve this issue?

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:

Posting Local File Info To A Php File!
I have a script that I run locally and im trying to get the info to post to a php file so that I can view it in a browser. What I need to know is how to set up the receiving php to post it to the .html . Now I thought it went along the line of creating the php file and putting it on the root of the server then running the local script against a that php info file and it would dump the info to a browser but it wont work like that (I'm guessing cause it's a local script and not on the web)

I know this line is sending it to the .php in that directory but I don't know how to set up the receiving php I guess is my problem.

gosub phpsend www.xxxxxxxxxxxxx.com /xxxxx/xxxxxxxxx.php %sendstring

I guess what I need to know is whats the best way to post the received data to a browser after the script runs. Or to set up the receiving php file as for outputting it I can create the page I just need to know how to receive it .

Writing To A Local File
We have a PHP/MySQL database application. A user would like to be able
to run a routine to read selected data from the database and export a
flat file to their local C: drive. After reviewing the documentation
and posts, it is not clear how to do this, or even if it is allowed by
the browser. If someone could point us in the right direction, we
would greatly appreciate it.

The application is hosted on a Linux server.
The users are required to use Internet Explorer running on Windows 2000
or XP (we also use VBScript).

Can I Launch A Local .bat File With PHP?
I need to write small web app that can launch a few .bat files from a local machine.
Is this possible with PHP, or would javascript be a better option? All i need to do is select the file (some HTML) then have a button to execute.

Check If A File Is Local
Is There A Function Or Method Which Can Check Wether A File Is Local.

Reading Local File Not On Server
I am trying to parse a file which is located on the users local drive and then take this data and put it into the mySQL DB. However, I get errors when I pass in a file path such as C:Documents and SettingsAdministratorDesktopfooSLInfo.txt.

Read File On Local Drive
lets assume that the sysadmin granted to read those files, what php functions needed? can u give me ur ideas how to do it?

How To Process A Local File Rather Than Just Read It
I can read a local file with

fopen("myFile.php");

However this gives me the source of the file (i.e. php code). I want
to get the results of the file after it has been evaluated (i.e. HTML).

The obvious way of doing this is

include 'myfile.php'

However, I want to process the evaluated result. For example:

echo htmlentities( include 'myfile.php' );

This doesn't work because the result of the include statement is true
or false rather than a string.

I'm sure this is very simple, but I'm just learning.

Writing A Local XML File From A Parsed URL? Similar To RSS
I am trying to pull the XML data from the following stream:
http://......and write it to a local file.

Actually, what I would like to do is take the above stream and display
it into a website... much like displaying RSS feeds on a webpage.

I looked at javascript, but someone there pointed me to the PHP group.
I may not have worded the subject correctly.

Copy Large XML Output To A Local File
I have a URL that when called generate a very heavy XML Feed like:

www.domain.com/generateXML.php?id=products

when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:

Selecting A File In Our Webspace From Our Local System
How to read a file which is in our webspace from localsystem in php.

PHP-generated Link To Local File Doesn't Work When Clicked On. Why?
I'm running an Apache server on my own computer (Windows XP Pro).

I wrote a simple PHP script (called test3.php) that I'm running by
putting the following URL in the address bar of the browser (Firefox)
....

http://localhost/test3.php

The script generates the following link using the echo statement ...

<a href="file:///C:/pictures/xyz.jpg"> Picture </a>

("C:/pictures/xyz.jpg", as you can guess by now, is an image file on
my harddrive, but it's not in the document root).

When I clicked on the link, nothing happened. However, if I
RIGHT-click on it and select "Copy link location" (which copies the
URL to the clipboard) and then paste the URL into the address bar of
the browser, the picture then displays correctly.

Why did it not work when I clicked on the link the first time, but it
only worked when I pasted the link to the address bar?

Is there some special notation/syntax that I need to use to get this
to work properly?

File Form - Keep Local Path Info On Reload
Is there a way to retain the local path info for a file form when the page reloads?

Copying File From Hosted Remote Sever To Local Machine
I am trying to use php to automate the copying of a file from my remotely
hosted directory to my computer. I have put together the following but it
will only do the copying from one directory to another on the remote server.
Reading the postings on these functions they suggest that it can be done but
it appears to be the case if your are hosting your site on the same machine
you want to copy the files to. Does anyone know if there are functions in
php to do the transfer from remote server to my machine or if the code below
will acheive this with modification?

<?php
$ftp_server = "xxxxxxxx";
$ftp_user = "xxxxxxx";
$ftp_pass = "xxxxxx";
$local_file = 'myfile.txt'
$server_file = 'myfile.txt'

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server");

$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
die("FTP connection has failed !");
}

// try to change the directory to myfilesdirectory
if (ftp_chdir($conn_id, "myfilesdirectory")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "";
} else {
echo "Couldn't change directory";
}

if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file";
} else {
echo "There was a problem";
}

// close the connection
ftp_close($conn_id);

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

How To Export A Table To HTML ...
In my project I want to export a table from a database to HTML format , in a simple table, and save the file to a specific dir/.

Put A Html Table In A Variable
I want to do the following: I want to draw a table in html (with the echo command) and put that in a variable so I can draw that table via that variable. I got the following (large table ;-) Code:

Php Condition In A Table With Html And Php
I would like to show a line in a tabel in html if there is quantity of
article choosed.

My code is:

<? if ($quantite1 0) {
echo('
<tr>
<td align="left" nowrap="nowrap">Article 1</td>
<td align="center"><? echo $quantite1 ?</td>
<td align="center">20 &euro;</td>
<td align="center"<? echo $montant1 ?&euro;</td>
</tr>');
}
else{
echo("");
}
?>

If there is no article >no line
If there is article >show the line

Problem: I can have the variable $quantite1 and $montant1 en php

Extract An HTML Table
I have an html-file, in which there are a table. I wants to extract this table. PHP Code:

HTML Table To Excel
I am running a MySQL SELECT query to dump the output to an excel file. I have tried various methods (CSV, PHP Classes to build excel docs, etc.) I ended up using a variation of a lot of the ones I have tried. I am using an HTTP header in PHP: PHP Code:

Displaying A HTML Table With PHP
I'm new to PHP and I'm trying to get my head around databases at the moment. So far I have a page that kinda takes the mickey and takes a few details from you, it then creates a cookie that can be removed later. It also prompts you to add the data you gave to a database.

All this works perfectly, but when it comes to displaying the results of the database, all I can show is the first entry in the table. Can someone please tell me how I'm supposed to see all of them?

I've read other articles but they don't make much sense to me.

BTW, the database details are as follows:

Database name: visualanteorg
Table name: people
Fields: id, name, shoe_size, job

As you will see if you choose to look at the pages, getting the information out is not a problem, it's just formatting it how I want it, so each entry appears under the other in the table.

Convert Html Table To Csv
i need to write a script to automatically convert some statistical data from an html table to csv there are two problems that i'm having, depending on the user or the options selected, some rows won't be shown, and some will so in the code, there are a heap of if statements to hide/show columns which makes it especially hard when we need to add new columns for the html view, something else i need to look into i guess.

i thought the easiest way, might be to use file_get_contents() to grab all the html code cos it's all laid out nicely already but then i thought about the colspans which would affect the comma seperatedness of the header columns (if you get that) does anyone know of a good, effective, scalable solution to this problem? Code:

How To Parse HTML TABLE
I have a problem with parsing html table. I need a script witch will pars html table from one site to another.

How To Count Html Table Row?
i am trying to echo "room_Type_break" field, the problem is it only prints twice of each room_Type. for e.g.

cal.php

room_type
--------
ensuite
ensuite
single    
single

book.php : Output:

single single

it is not printing out ensuite...any idea?

cal.php
if($qty !== '0'){
$p=0;
while($fday<$tday){
echo "<td>$room_Type<input type='text' name='room_Type_break' value='$room_Type'></td>
$p++;

}echo "<input type='hidden' name='count' value='$p'>"; }

book.php
for ($i = 0; $i <= $_POST['count']; $i++) {
 
 $room_Type_break = $_REQUEST['room_Type_break_'.$i.''];

echo "$room_Type_break";
}

Remove Text Header In Text File
I have been having trouble removeing two header lines at the top of my txt file. You will see in my code the different things I have tried but with no luck. Below I posted my script and data. I am doing a few other things in my script as you will notice but this is the only thing I am having troble with. Code:

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!

Converting Table Data From HTML To PHP
I have a problem converting data from a html file, to a 3 way split. (header.php index.php and footer.php, Reason being PHP won't parse the following line,
<table width="37%" border="0" cellspacing="0" cellpadding="0" height="163">
I think it all revolves around the % sign, does anyone have any ideas about how to fix it without limiting the width to X amount of pixels?

Create Html Table With Php Result?
I'm looking to display 5 records in one rows, from the database. What i mean is, basically, let's take the "emails" as an example. I have a table with 100s of email
addresses. Now i want to display these email addresses on a html table, but i want to display only 5 email adresses per table row, then the next 5 in the next table row and so
on.

HTML Table With Data From Two Recordsets
I have two MySQL tables, say one is author and one is books. Author contains a unique PK say author_id Books contains an author_id also which links across to the author table. Usual stuff. My problem is getting at the info.

If I wanted to display the info, in it's mnost basic format, I would set up a HTML table with the columns and repeat the row. PHP Code:

Extract Data From Table Html
I would like to extract data from the table attached.
Could someone help me to create the regular expression to grab that
informations?


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