Aravinthan
-
Posts
162 -
Joined
-
Last visited
Never
Posts posted by Aravinthan
-
-
What do you mean?
I dont understand your question
-
I would need them, because once the data inserted into the DataBase, I would like to once in awhile export it back to this format.
So I would still need to insert these datas in the DB no?
-
Wow ok thanks,
But wont it be long to give that for all the data I need?
And also there is 3500 datas like this...
Ok I will try to re-explain.
63 61 54 61 63 60 63 70 66 63
63 71 68 61 115 42 10 0 1 4 1
1973 24 6 950000 0 1991 4 17 98
0 0 0 0
0 0 0 0
179000 3000 908 0 0 0
1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 4 194 7 3
0 0 0 0 0
-
Milan Hnilicka
drafted
150080070070075095144103068062125080125
1.16 (24.3.2002)
1.16 (24.3.2002)
0 0 98 65 70
This is the 1st players data.
What I want is to insert:
The first 7 lines, I need to split them apart, each numbers = different strings = different colum name for the Database.
The lines 8,9 and 10 dont need it.
11 and 12 same as the first 7 ones.
Dont need 13, but need 14.
Dont need 15, 16, 17, 18, 19
But the line 20 need it like the first 7 ones.
But I would need to insert the lines I dont need anyways, as after that I would like to export the MYSQL data back into this format.
So What I want, lets say line 1 colum 1: 63, I want that to be inserted into a MYSQL table under a colum named C1 for ex, then 61 under C2 colum, and so one. For the lines I dont need: 8,9,10,13,15, 16, 17, 18, 19
I would like to add them in a colum named: line 8, line 9, etc.
I dont know if its more clear now...
Thanks again for your help,
Ara
-
Ok so this is what I have:
<?PHP $lines = file('players.txt'); while (!feof($lines) ) { $lineOneArray = explode(" ", $lines[1]); print_r($lineOneArray); } fclose($file_handle); ?>
And this is the result:
http://liguedhockeysimule.x10hosting.com/converter/texttosql.php
Is there something I missed?
EDIT:
<?PHP $lines = file('players.txt'); $lineOneArray = explode(" ", $lines[1]); print_r($lineOneArray); fclose($lines); ?>
Changed it to this, and the output:
.Array ( [0] => [1] => 63 [2] => [3] => 61 [4] => [5] => 54 [6] => [7] => 61 [8] => [9] => 63 [10] => [11] => 60 [12] => [13] => 63 [14] => [15] => 70 [16] => [17] => 66 [18] => [19] => 63 [20] => )
Warning: fclose(): supplied argument is not a valid stream resource in /home/liguehs/public_html/converter/texttosql.php on line 12
How can I show the other lines? And How can I update a MYSQL table with it?
-
Oh NVM just realised the difference.
So If I understand well,
I replace:
$file_handle = fopen("players.txt", "rb");
By this:
$lines = file('myfile.txt');
And this :
while (!feof($file_handle) ) {
By:
while (!feof($lines) ) {
$parts = explode(' ', $line_of_text);
By this:
$lineOneArray = explode(" ", $lines[1]);
And I out put it how?
Thanks for your help,
Ara
-
To abazoskib :
I tried that:
http://liguedhockeysimule.x10hosting.com/converter/texttosql.php
To MadTechie:
Thats what I have no?
-
Hi guys,
Ok so first of all here is my problem:
I would like to read a text file and then format it to a SQL type of format.
So I tought, lets start it easy. What I am trying is to take a line and insert it into an array. Then output the array.
Simple right? Thats what I tought until, I realised the lines dont have the same number of datas. Some has 10, some has 5.
And there is also some lines that I need to split up a part and some that can stay toghter.
Well, I'll show you guys the code:
<?PHP $file_handle = fopen("players.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode(' ', $line_of_text); echo "$parts[0] $parts[1] $parts[2] $parts[3] $parts[4] $parts[5] $parts[6] $parts[7] $parts[8] $parts[9]<BR>"; } fclose($file_handle); ?>
Only the first 5 gets shown.
I will attach the text file that I would like to format.
But here is a sample of it:
3500
63 61 54 61 63 60 63 70 66 63
63 71 68 61 115 42 10 0 1 4 1
1973 24 6 950000 0 1991 4 17 98
0 0 0 0
0 0 0 0
179000 3000 908 0 0 0
1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 4 194 7 3
0 0 0 0 0
-
Milan Hnilicka
drafted
150080070070075095144103068062125080125
1.16 (24.3.2002)
1.16 (24.3.2002)
0 0 98 65 70
This is the first player.
The 3500 at the top, is just to say that there is 3500 players, but it doenst matter too much.
Ok so here is the details:
The first 7 lines, I need to split them apart, each numbers = different strings = different colum name for the Database.
The lines 8,9 and 10 dont need it.
11 and 12 same as the first 7 ones.
Dont need 13, but need 14.
Dont need 15, 16, 17, 18, 19
But the line 20 need it like the first 7 ones.
But I would need to insert the lines I dont need anyways, as after that I would like to export the MYSQL data back into this format.
So can some one help me on doing this?
I am not sure if I am clear... If I aint please dont hesistate to ask more information...
Thanks for your help and Time,
Ara
-
Hi guys,
I want to read a MYSQL data and then output it as a XML file....
Easy right?
Well, I reduced the coding to this simplest thing:
<?php header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; echo "<slide_show>"; echo "<photo>./images/DCP_0730.jpg</photo>"; echo "</slide_show>"; ?>
But it still doesnt work.
In Firefox I get:
XML Parsing Error: not well-formed
Location: http://liguedhockeysimule.x10hosting.com/default.xml
Line Number 7, Column 7:
echo "<slide_show>";
------^
In IE 8 I get:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Invalid at the top level of the document. Error processing resource 'http://liguedhockeysimule.x10hosting.com/default.xml'....
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
-------------------------------------------------^
I looked and looked, still cant seem to find the error....
I am pretty sure it is really a dumb mistake that I made somewher :oops:
But I cant find it,
I changed the code to single qutoes, back to to double....
But I guess I need to or something....
You can't imagine how stupid I feel lol
Thanks for your help,
Ara
-
Hi guys,
I want to read a MYSQL data and then output it as a XML file....
Easy right?
Well, I reduced the coding to this simplest thing:
<?php header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; echo "<slide_show>"; echo "<photo>./images/DCP_0730.jpg</photo>"; echo "</slide_show>"; ?>
But it still doesnt work.
In Firefox I get:
XML Parsing Error: not well-formed
Location: http://liguedhockeysimule.x10hosting.com/default.xml
Line Number 7, Column 7:
echo "<slide_show>";
------^
In IE 8 I get:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Invalid at the top level of the document. Error processing resource 'http://liguedhockeysimule.x10hosting.com/default.xml'....
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
-------------------------------------------------^
I looked and looked, still cant seem to find the error....
I am pretty sure it is really a dumb mistake that I made somewher :oops:
But I cant find it,
I changed the code to single qutoes, back to to double....
But I guess I need to :banghead: or something....
You can't imagine how stupid I feel lol
Thanks for your help,
Ara
-
Ok, so I changed my tables:
games:
gameid, ga, gf and winner
players:
gameid, goals, assists and points.
And this is my coding:
result = mysql_query("SELECT * FROM games, players WHERE games.gameid = players.gameid ORDER BY gameid DESC LIMIT 5 ",$link); while($row = mysql_fetch_array($result)) { echo "Game Number: " .$row['gameid']. "</br>"; echo "A " .$row['gf']. "-" .$row['ga']. " " .$row['winner']. "<br/>"; echo "Scorers:<br/>"; echo "<center><table border='1' width='100%' bordercolor='#413326'> <tr> <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Lastname</font> <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Goals</font> <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Assists</font> <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Points</font>"; echo "</tr> <tr>"; echo "<td>" . $row['lname'] . "</td>"; echo "<td width='7%'>" . $row['lnameg'] . "</td>"; echo "<td width='7%'>" . $row['lnamea'] . "</td>"; echo "<td width='7%'>" . $row['lnamep'] . "</td>"; echo "</tr></table></center>"; }
But there is no data that is getting displayed....
Thanks for your help,
Ara
-
Hi,
I am making a personal site about me and I wanted to show my teams last 5 games scores and the scorers. So I made a DB:
Gameid
gf
ga
winner
lname
goals
assists
points
And now I am outputting it:
<?php
$link = mysql_connect ("localhost", "user", "pass")
or die("mysql_error()");
mysql_select_db ("stmaxel_stats", $link);
$result = mysql_query("SELECT * FROM `games` ORDER BY gameid DESC LIMIT 1 ",$link);
while($row = mysql_fetch_array($result))
{
echo "Game Number: " .$row['gameid']. "</br>";
echo "A " .$row['gf']. "-" .$row['ga']. " " .$row['winner']. "<br/>";
echo "Scorers:<br/>";
echo "<center><table border='1' width='100%' bordercolor='#413326'>
<tr>
<th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Lastname</font>
<th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Goals</font>
<th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Assists</font>
<th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Points</font>";
echo "</tr>
<tr>";
echo "<td>" . $row['lname'] . "</td>";
echo "<td width='7%'>" . $row['lnameg'] . "</td>";
echo "<td width='7%'>" . $row['lnamea'] . "</td>";
echo "<td width='7%'>" . $row['lnamep'] . "</td>";
echo "</tr></table></center>";
}
?>
The thing is that it outputs the same game 2 times. I just saw my mistake, I enter the different players who had points in this game. But differently. So there is more than 1 entry for the same game. And when I try to output it, it shows in 2 different tables. Is there any way that I can show it in only 1 table?
I am not sure if I am clear, if you dont understand let me know and I'll try to clear myself.
THanks for your help and time,
Ara
Reading a text file
in PHP Coding Help
Posted
Try to re-explain.
And I want it to be formatted to something like this: