How do I externally update a table in my htm file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • w33nie
    New Member
    • Jan 2007
    • 56

    How do I externally update a table in my htm file?

    I really have no idea where to start for this, as i'm VERY new to scripting, but i do have intermediate skills at html, so i thought i'd try and get a nudge in the right direction from a help site.

    I'm currently making a website where I'll need to have a rankings table of teams for an online computer game league.
    I'll put this table in my .htm file, as I want it to be integrated in the page, and look just like a regular table would.
    but, I want to be able to externally update the data in this table, so I don't have to change the .htm file after every match, updating the teams, their positions on the table and the rest of the data.

    the primary aim of this method for me, is for ease of use.
    i would also like this external file to be able to sort the positions of teams on the table for me, based on the points this team has won.

    so, does anyone know of a format of file or external source i could use? like PHP or another script?
    and how i would achieve this goal.


    cheers.
    rowan.
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    What do you have available PHP,ASP, etc... I'm going to move this thread to the appropriate forum.

    Comment

    • w33nie
      New Member
      • Jan 2007
      • 56

      #3
      umm, ive got mySQL and PHP4/PHP5 available to use in the hosting plan, but i just lack any knowledge of coding in them.

      which one do you think would be more appropriate? for the basic aims i'm trying to achieve.

      Comment

      • AricC
        Recognized Expert Top Contributor
        • Oct 2006
        • 1885

        #4
        PHP4/PHP5 are the versions the main thing is that you can run PHP on your site. I'm going to move this thread to the PHP forum.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          First you have to make a choice between storing the data in a flat text file or in a MySQL database.

          Both solutions can be externally updated via a grid script and both can be read, sorted and stored into your html page.

          MySQL is easier to handle and program, but has more server overhead. A flat file is more difficult (column positions etc.) to program but has less overhead.

          So it's up to you to first decide how and where you want your data to be stored.

          Ronald :cool:

          Comment

          • w33nie
            New Member
            • Jan 2007
            • 56

            #6
            well i think as a complete beginner i should use mySQL, if its easier.
            i'll only need a maximum of 72 text fields in the table, so there shouldn't be too much server overhead, right?

            so if i'm to use mySQL, could you point me to a decent tutorial for integrating it into a table in html?
            i havent downloaded mySQL though, and havent a clue what to do once i have got it, anyway.

            thanks for all the help in advance.

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              There are a lot of decent to good tutorials, depending on your requirement. Try any (or all) of the following MySQL tutorials

              Founded in 1997, DEVShed is the perfect place for web developers to learn, share their work, and build upon the ideas of others.


              Learn how to use MySQL with PHP in Tizag.com's MySQL and PHP lesson.





              W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


              Good luck.

              Ronald :cool:

              Comment

              • w33nie
                New Member
                • Jan 2007
                • 56

                #8
                thanks.
                well... currently, im on the freewebmasterhe lp tutorial.
                i've downloaded mySQL, gotten an account, and am trying to set up phpMyAdmin, but the setup.php file won't open in IE or firefox... and i need it to. otherwise i cant use phpMyAdmin.

                what do you suggest i do?

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #9
                  I'd suggest that you forget about phpMyAdmin for now and setup your MySQL server first using the command line interface. You'll learn more about Mysql and the SQL statements using that. If not, you can also execute SQL via a server script, like PHP.

                  First get your server setup right, then worry about the user interface like phpMyAdmin.

                  Ronald :cool:

                  Comment

                  • w33nie
                    New Member
                    • Jan 2007
                    • 56

                    #10
                    well i really have no idea what i'm doing, and the server won't set up properly.

                    so, the other option, a flat text file.
                    how do i integrate that with my html file, and will it allow automatic sorting based on the information in the flat text file?

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #11
                      Hi there

                      I have another, extreeemly simple solution, wich I far from being as good as anything using any form of a database.

                      In your html file Im assuming you have a table and that you want to add a tr row to the end of it before you close it?

                      If so you could add a html comment before you close the table and have a php file replace the comment with a new row.

                      Wich could be done somewhat like this...
                      [PHP]// Read the file
                      $filePath = "myhtml.htm l";
                      $fh = fopen($filePath , "r");
                      $contents = fread($fh, filesize($fileP ath));
                      fclose($fh);

                      // Change the contents
                      $newRow = "
                      \n<tr> <td> Somedata </td><td>". $_POST['fieldname'] ."</td></tr>
                      \n<!-- what? -->";
                      $output = str_replace("<!-- what? -->", $newRow, $contents);

                      // Overwrite the file with new content
                      $fh = fopen($filePath , "w");
                      fwrite($fh, $output);
                      fclose($fh);[/PHP]

                      This php code would be the target of a html <form> wich would provide the <input> field named 'fieldname'.
                      You would obviously have to edit to $newRow variable in the PHP to create the output you need, and create the html form that would call the php.

                      Hope this helps you :)

                      Comment

                      • w33nie
                        New Member
                        • Jan 2007
                        • 56

                        #12
                        thanks for the help, but, haha, i dont think u realise how much of a beginner i am.
                        because i don't understand that.
                        but i do want a database solution, something that will allow sorting and mathematical problems in it.

                        so im trying to get mySQL working again, ill keep trying, and hopefully i'll get it in the end.

                        ill post again if i run into any problems.

                        Comment

                        • Atli
                          Recognized Expert Expert
                          • Nov 2006
                          • 5062

                          #13
                          I see :P

                          I think MySQL comes with a ms installer so it really should be no problem.

                          This here is a file I created for myself, instructions on how to manually install PHP on Apache server with MySQL.

                          How to manualy install PHP on Apache server with MySQL with Win XP

                          Note: this is based on a rather old version but should work fine tho

                          Comment

                          • w33nie
                            New Member
                            • Jan 2007
                            • 56

                            #14
                            well finally i've managed to get it working for the most part,
                            but how do I sort the table by a variable?

                            i can sort it in phpmyadmin, but once i put it in the .php file, its no longer sorted

                            Comment

                            • ronverdonk
                              Recognized Expert Specialist
                              • Jul 2006
                              • 4259

                              #15
                              In order to answer that you must show the PHP and the MySQL code you use to extract the data from the db.

                              Ronald :cool:

                              Comment

                              Working...