At 01:49 03/01/2004 +0000, you wrote:
Date: Sat, 3 Jan 2004 12:04:11 +1100 (EST)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Subject: grabbing text from a webpage and putting it in a query.

All I can suggest is that you cut and paste the desired text into notepad and save it as a file. This is because their pages are not regular nor xhtml (or even well formed HTML) that you cannot parse the page reliably. So, cut and paste the text only and save it first using notepad, before loading it into PHP and slicing it up into an array of lines.

Then try using a regular expression in a loop, to create your INSERT query.

This might work for one of your team lines (untested so you'll have to look through the preg expression syntax to check how to split the lines correctly it if it doesn't work ;-)

$matcharray=array("Brisbane Lions v Collingwood at Gabba (night)");
//      Assumes you set up a loop and are capable to split
//      your text by newlines into an array of strings
foreach ($matcharray as $string) {
        $matching="/^([a-z ]+) v ([a-z ]+) at .*/iu";
        if (preg_match($matching,$string,$matches)) {
                $query="INSERT INTO games (team1, team2)
                        VALUES ('".$matches[1]."','".$matches[2]."')";
//              mysql_query($query,$link);

So is there a way to grab text from an external
website (away from my server) and put it in a query I
setup on my site?

I'm seeking the text, not the HTML or source.  At
pressent I am copying the rounds into notepad and
entering them in the database 1 by 1.  This takes ages
as there is 16 teams in each round and 22 rounds. :P
Takes alot of time to complete so was looking for a
faster way. :)

Any ideas?



-- PHP Database Mailing List ( To unsubscribe, visit:

Reply via email to