473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

w33nie
56
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.
Jan 18 '07 #1
16 1911
AricC
1,892 Expert 1GB
What do you have available PHP,ASP, etc... I'm going to move this thread to the appropriate forum.
Jan 18 '07 #2
w33nie
56
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.
Jan 18 '07 #3
AricC
1,892 Expert 1GB
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.
Jan 18 '07 #4
ronverdonk
4,258 Expert 4TB
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:
Jan 18 '07 #5
w33nie
56
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.
Jan 18 '07 #6
w33nie
56
thanks.
well... currently, im on the freewebmasterhelp 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?
Jan 18 '07 #8
ronverdonk
4,258 Expert 4TB
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:
Jan 19 '07 #9
w33nie
56
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?
Jan 19 '07 #10
Atli
5,058 Expert 4TB
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.html";
$fh = fopen($filePath, "r");
$contents = fread($fh, filesize($filePath));
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 :)
Jan 19 '07 #11
w33nie
56
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.
Jan 19 '07 #12
Atli
5,058 Expert 4TB
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
Jan 19 '07 #13
w33nie
56
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
Feb 6 '07 #14
ronverdonk
4,258 Expert 4TB
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:
Feb 6 '07 #15
w33nie
56
well here's the code in my .php file.

Expand|Select|Wrap|Line Numbers
  1. <? $hostname = "p3smysql17.secureserver.net"; // The mySQL DB server. 
  2. $username = "acssl_table"; // The username you created for this database. 
  3. $password = "Victoria3"; // The password you created for the username. 
  4. $usertable = "table"; // The name of the table you made. 
  5. $dbName = "acssl_table"; // This is the name of the database you made. 
  6.  
  7. MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
  8. @mysql_select_db( "$dbName") or die( "Unable to select database"); 
  9. ?> 
  10. <? 
  11. //error message (not found message)begins 
  12. $XX = "No Record Found, to search again please close this window"; 
  13. //query details table begins
  14. $query = mysql_query("SELECT * FROM `table` LIMIT 0, 30 "); 
  15. while ($row = @mysql_fetch_array($query)) 
  16. $variable1=$row["team"];
  17. $variable2=$row["played"]; 
  18. $variable3=$row["won"]; 
  19. $variable4=$row["drawn"];
  20. $variable5=$row["lost"];
  21. $variable6=$row["for"]; 
  22. $variable7=$row["against"]; 
  23. $variable8=$row["difference"]; 
  24. $variable9=$row["points"];
  25. //table layout for results 
  26.  
  27. print ("<tr>");
  28. print ("<td width='150'><span class='BodyTable'>$variable1</span></td>");
  29. print ("<td width='50' align='center'><span class='BodyTable'>$variable2</span></td>");
  30. print ("<td width='50' align='center'><span class='BodyTable'>$variable3</span></td>");
  31. print ("<td width='50' align='center'><span class='BodyTable'>$variable4</span></td>");
  32. print ("<td width='50' align='center'><span class='BodyTable'>$variable5</span></td>");
  33. print ("<td width='50' align='center'><span class='BodyTable'>$variable6</span></td>");
  34. print ("<td width='50' align='center'><span class='BodyTable'>$variable7</span></td>");
  35. print ("<td width='75' align='center'><span class='BodyTable'>$variable8</span></td>");
  36. print ("<td width='75' align='center'><span class='BodyTable'>$variable9</span></td>");
  37. print ("</tr>"); 
  38. }
  39. //below this is the function for no record!!
  40. if (!$variable1)
  41. print ("$XX");
  42. //end 
  43. ?>
and these are screenshots of the database,
didnt think theyd be useful, but I really don't know what you're looking for, so:

here's one of the table

and one of the data
Feb 7 '07 #16
w33nie
56
oh, and could someone explain how to do that in phpMyAdmin 2.7
Feb 8 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Marc | last post by:
Hi all, I have a problem with managing the interchange between COM/Excel and Python if the user closes the workbook externally. Everything works fine as long as the user only uses the exit...
3
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
1
by: revolnip | last post by:
As attached is the code : <% Option Explicit dim lngTimer lngTimer = Timer %> <!--#include file="Connect.asp" --> <!--#include file="Settings.asp" --> <!--#include file="Common.asp" -->
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
6
by: Eugene | last post by:
Summary: ---------- Updates against UNION ALL view does't do branch elimination, but rather reads all the branches (partitions). The case scenario(DB2 V8.1.4a ESE, AIX 5.2):...
4
by: Ian Davies | last post by:
Hello I have seen some tutorials to put a update a counter field in a record. I have the counter field in a table that also has a field for a path to file. I display the records in a table on...
6
by: Rudy | last post by:
Hello all! I'm working in vb/ado.net I want to to have a message box pop up based on a result of a update on a SQL table. How do I do that so it automaticly pops up after the update is...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
3
by: Shawn T | last post by:
I have an application with a page that has a web user control When I call that page that has this user control, locally (http:// localhost/ApplicationX/default.aspx) and also externally ie...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.