Jump to content

Aravinthan

Members
  • Posts

    162
  • Joined

  • Last visited

    Never

Posts posted by Aravinthan

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

    And I want it to be formatted to something like this:

    Update( SET name = 'Milan Hnilicka', shooting = '63', playmaking = '61', stickhandling = '54', checking = '61', marking = '63', 
    hitting = '60', skating = '63', endurance = '70', penalty = '66', faceoffs = '63', leadership = '63', strength = '71', 
    potentiel = '68', consistency = '61', greed = '115',fighting = '42', click = '10', team='0', main_position='1', country='4', 
    handed='1', birth_year='1973', birth_day='24', birth_month='6', salary='950000', contract_lenght='0', draft_year='1991',
    draft_round='4', drafted_by='17', rights='98', week_goals=0', week_assists='0', week_gwg='0', month_goals='0', month_assists='0', 
    month_gwg='0', record_goals='179000', record_assists='3000', record_points='908', no_trade_switch='0', two-way_switch='0',
    player-team_option='0', status='1', rookie='0', considering_offer_data='0', team_offering='0', amount_time_spent_considering='0',
    injury='0', line8='0  0  0  0  0  0  0  0  0  0', line9='0  0  0  0  0  0  0  0  0  0', line10='0  0  0  0  0  0  0  0  0  0',
    goal_streak='0', point_streak='0', total_gp='0', suspended_game='0', training='0', weight='194', height='7', status_in_organization='3',
    best_streak_games='0', best_streak_gwg='0', best_streak_assists='0', best_streak_points='0', best_streak_goals='0', line13='-',
    line15='/n', drafted='drafted='drafted', line17='150080070070075095144103068062125080125', line18='1.16 (24.3.2002)', line19='1.16 (24.3.2002)',
    attitude='0', alternate_position='0', nhl_rights='98', injury_prone='65', overral_draft='70' Where name='$name');
    
    I think I didnt write the correct Update code, but you get the point... I hope.
    
    And I need this to be the same thing for all the players. I guess we can do that with a while loop, no?
    

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

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

  4.  

     

    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

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

     

  6. 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  :facewall:  or something....

    You can't imagine how stupid I feel lol

    Thanks for your help,

    Ara

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

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

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.