473,574 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

geting values from html table

Hello there ;)

I'm trying to build a scrip that would open a page that has a table and then
get all the values as variables so I can put them in a MySQL DB.
The problem is that I don't really know where to start...

This was my idea split the page in two cause there's 2 tables and I just
want the second one, then clean up what I don't want and finally assign the
variables...

something along these lines... sadly this doesn't work :(

<?php
ini_set('error_ reporting', E_ALL);

ini_set('user_a gent','MSIE 4\.0b2;');

$handle = fopen("http://www.scuniverse. net/Hist/HOF.htm", "r");
$page = fread($handle, 20000);
$row = explode("TR",$p age);

$i=0;

while ($i < 31)
{
list ($Rank, $Name, $Castle, $Land, $KS, $Race) = explode("TD",$r ow[$i]);
$i++;
}

Jul 17 '05 #1
3 2328
"Marco" <mpgtlatbluewin .ch> wrote in message news:<42******* ***@news.bluewi n.ch>...
ini_set('user_a gent','MSIE 4\.0b2;');

$handle = fopen("http://www.scuniverse. net/Hist/HOF.htm", "r");
$page = fread($handle, 20000);
$row = explode("TR",$p age);

$i=0;

while ($i < 31)
{
list ($Rank, $Name, $Castle, $Land, $KS, $Race) = explode("TD",$r ow[$i]);
$i++;
}


theoreticly it somethjink like that

$h=implode("",f ile("somefile/fromsomewhere/test.htm"));
$h=preg_replace ('/\<[\/]TABLE\>/','--TABLE--',$h);
list($trash1,$t able,$trash2)=e xplode("--TABLE--",$h);
$table=preg_rep lace("/\<TR.+\>/","",$table );
$table=preg_rep lace("/\<TD.+\>/","",$table );
$row_array=expl ode("</TR>",$table);
$sz=sizeof($row _array);
for($i=0; $i < $sz; $i++) {
list ($Rank, $Name, $Castle, $Land, $KS, $Race)=explode( "</TD>",$row_arra y[$i]);
}

i didnt try it :)
it is simple, lame but it shoud explain the algorythm:)
Jul 17 '05 #2

"Paulius" <ma*****@gmail. com> wrote in message
news:ff******** *************** ***@posting.goo gle.com...
"Marco" <mpgtlatbluewin .ch> wrote in message
news:<42******* ***@news.bluewi n.ch>...
ini_set('user_a gent','MSIE 4\.0b2;');

$handle = fopen("http://www.scuniverse. net/Hist/HOF.htm", "r");
$page = fread($handle, 20000);
$row = explode("TR",$p age);

$i=0;

while ($i < 31)
{
list ($Rank, $Name, $Castle, $Land, $KS, $Race) = explode("TD",$r ow[$i]);
$i++;
}


theoreticly it somethjink like that

$h=implode("",f ile("somefile/fromsomewhere/test.htm"));
$h=preg_replace ('/\<[\/]TABLE\>/','--TABLE--',$h);
list($trash1,$t able,$trash2)=e xplode("--TABLE--",$h);
$table=preg_rep lace("/\<TR.+\>/","",$table );
$table=preg_rep lace("/\<TD.+\>/","",$table );
$row_array=expl ode("</TR>",$table);
$sz=sizeof($row _array);
for($i=0; $i < $sz; $i++) {
list ($Rank, $Name, $Castle, $Land, $KS,
$Race)=explode( "</TD>",$row_arra y[$i]);
}

i didnt try it :)
it is simple, lame but it shoud explain the algorythm:)


Thanks, didnt try it yet but your idea pleases me already :D
Jul 17 '05 #3
DH
Marco wrote:
Hello there ;)

I'm trying to build a scrip that would open a page that has a table and then
get all the values as variables so I can put them in a MySQL DB.
The problem is that I don't really know where to start...

This was my idea split the page in two cause there's 2 tables and I just
want the second one, then clean up what I don't want and finally assign the
variables...

something along these lines... sadly this doesn't work :(

<?php
ini_set('error_ reporting', E_ALL);

ini_set('user_a gent','MSIE 4\.0b2;');

$handle = fopen("http://www.scuniverse. net/Hist/HOF.htm", "r");
$page = fread($handle, 20000);
$row = explode("TR",$p age);

$i=0;

while ($i < 31)
{
list ($Rank, $Name, $Castle, $Land, $KS, $Race) = explode("TD",$r ow[$i]);
$i++;
}


<?php header("Content-Type: application/vnd.ms-excel");?>
<table border=1>
<tr><th>col1</th><th>col2</th></tr>
<tr><td>Cell 1</td><td>Cell 2</td></tr>
</table>
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1518
by: Matik | last post by:
Hello everyone, I was wondering. Is it possible, to recive an event from ActiveX into database? I was looking alredy with notification services, but I think that's the wrong way. Lets say, that there is a ActiveX which realize some tasks. The database trigers the ActiveX like below:
2
11302
by: Bhavin G | last post by:
Hi there , I am pretty new at javascripting and i am having this huge problem. I am using asp.net and C# webapplication. In my asp.net aspx file I have a place holder for taking an html table dynamically. I create a html table Time | Data1 | Data2 | Data3 type, in which the columns are not fixed, hence i am building it dynamically in c#...
13
2477
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks). Currently this code write all columns to a single row which works but is not what the boss wants. If anyone has suggestions how you would do a...
14
7953
by: Satheesh Babu B | last post by:
hai.. am having a checkboxlist..now how do i get the value of the checkbox that is checked in checkboxlist using javascript? Thanks in advance.... Regards,
2
2329
by: sujith.bolar | last post by:
Hello I am using a <form method="post"to submit values to the processing agent. If the processing agent returns an error, I call the history.go(-1) or history.back() function to reload the page. The page does reload but all the values entered disappears. I am using Java Script and html. Code: ---------------------
2
1537
by: rksadhi | last post by:
/*Geting error ---object reference not set to an instance---at bold line----plz reply asap thanks in advance*/ cmd = new OleDbCommand ("SELECT e.emp_id,e.email, m.email AS Email FROM emp_details e INNER JOIN emp_details m ON e.spid = m.emp_id AND e.emp_id='" + e_id + "'",conn); dr=cmd.ExecuteReader(); if(dr.Read()) {...
1
1841
by: shyamg | last post by:
hi.. in this below code i have to call the function in thsi function ia hve hide some fields in the body onload but its working fine but when ever i click that jsp page the page loding time its shows all the filds and that is hide .can i use any other event in this ..... <script language="javascript"> function Mysee(){ ...
8
2169
by: ahilar12 | last post by:
Hi experts, I have a form with many textboxes,listboxes in php.I have a edit button to edit the values in the form.once i click the edit button the existing values should be displayed so that the user can edit those particular values and also that should be updated in the mysql database.kindly reply me as early as possible. Thanks
9
2610
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of the main floors of the main house: Part C: Gross Floor Area of the basement or cellar: Part D: Gross Floor Area of the attic:
0
7843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5336
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1375
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.