Google Answers Logo
View Question
 
Q: Syndicate headlines from our website (PHP/mySQL) via XML and Javascript? ( Answered 4 out of 5 stars,   0 Comments )
Question  
Subject: Syndicate headlines from our website (PHP/mySQL) via XML and Javascript?
Category: Computers > Programming
Asked by: srv-ga
List Price: $30.00
Posted: 06 Aug 2002 23:19 PDT
Expires: 05 Sep 2002 23:19 PDT
Question ID: 51612
Hi, 
We would like to syndicate our headlines to other websites so they can
have our latest 5 or 10 headlines on their site and we provide them
the feed. We run PHP/mySQL at the front and backend. I was thinking
that we could write to a static XML file every 3600 secs (hour) wiht
the latest news and then all the websites would just hit that file
directly rather than hammering the database for every article, every
time. I would then like to have a script that they could put on their
webpage that calls the XML file and displays the headlines on their
page. I figure javascript may be the way to go as PHP will limit it
use to those runnign PHP on their server. We would also need the
javascript to offer a few different HTML choices - perhaps a header
and a 1 pixel border and then 4 or 5 choices of different colors.

You can see our own current headlines on our front page at
www.iseekgolf.com about half way down on the left hand side. SO
effectively we just want those exact headlines but be able to offer
them on other sites.
Answer  
Subject: Re: Syndicate headlines from our website (PHP/mySQL) via XML and Javascript?
Answered By: joseleon-ga on 07 Aug 2002 00:02 PDT
Rated:4 out of 5 stars
 
Hello, srv:

  You have just described a system is already invented or at least it
could be useful to you to start on your own, let me explain how it
works. Let's call SERVER the site that serves the news and CLIENT the
site that shows the news. The client, to show the news, requests a
file (usually backend.php, rss.php, etc) stored on the server and that
file, dumps out an XML file which contains the latest news from that
site in an specific format (RSS). The client is responsible to don't
make a request to the server site for each page, it must have a simple
counter to store the last time requested the page and calculate if
it's time to do it or not. Why use XML?, because the client can
transform/manage the news in the way they want, they can change layout
or do whatever they want with that information.
  
Introduction to RSS  
http://www.webreference.com/authoring/languages/xml/rss/intro/  

RSS Delivers the XML Promise
http://www.webreview.com/1999/10_29/webauthors/10_29_99_2a.shtml

Why Would You Use RSS?
http://www.webreview.com/1999/10_29/webauthors/10_29_99_2b.shtml

I know this is not *exactly* what you want, but it's the general way
to do it. For what you want I will create simple PHP script which
creates several html files, one for each layout you offer to your
clients, with all your updated news. This PHP script must be executed
at an specified interval, you can use the cron daemon of your linux
server to achieve that:

Crontab tutorial
http://www.superscripts.com/tutorial/crontab.html

You just have to add a line to tell PHP to execute your script within
an specified interval and that's all, now your customers, just have to
use SSI includes to include yor html files inside their code.

SSI Include
http://www.htmlite.com/SSI003.shtml

Another way (I think is the better for you) would be to create
javascript code instead of html code for each layout and let them
include it this way:

<!--                  index.html                      -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<SCRIPT language="JavaScript" src="layout1.js">

</SCRIPT>
</body>
</html>
<!--                  index.html                      -->


<!--                  layout1.js                      -->
document.write('News title1<br>');
document.write('News title2<br>');
document.write('News title3<br>');
<!--                  layout1.js                      -->

So they don't need PHP or SSI to add your news to their site.

I hope this is what you are looking for, in any case, don't hesitate
to request any clarification, I will be more than happy to help you.

Regards.
P.S. By the way, iseekgolf.com looks really good.

Request for Answer Clarification by srv-ga on 07 Aug 2002 01:15 PDT
Hi Mate,
Thanks for the quick response...
I couldn't find the code you wrote for it anywhere..or is that coming
in a later post?

Jason

PS - Thanks for the kind words regards the site....:)

Clarification of Answer by joseleon-ga on 07 Aug 2002 01:30 PDT
I think you mean the code for RSS system, isn't it? There's is no code
and there is code, I mean, there are many implementations of it on
many languages, are you interested on it or are you going to implement
your own system with Javascript/XML?. If you use existings RSS
systems, your users will need PHP on their servers to retrieve your
news.

In any case, here is the link to the many PHP scripts out there to
provide RSS news feeds.

HotScripts.com
http://www.hotscripts.com/search/?bool=AND&query=rss&category=PHP

I hope it will be useful.

Request for Answer Clarification by srv-ga on 07 Aug 2002 14:34 PDT
Hi,
I think things are a little confused..
I needed someone to write a basic system for me, I know what to do
roughly as I wrote most of the website myself...but I do not have the
time to do the whole lot. I have already been to hotscripts, zend,
phpbuilder etc as I go there alomst daily but thought I could get
something done here quicker and more effciently. If I only needed to
know how to do it I certainly would not have paid $60 australian for
soemthing i already know.

What I wanted was the code (just example jv and .rss would be fine) to
syndicate my headlines thru an RSS or XML file with a javascript
frontend for other sites to use....not a few websites of which I was
already aware.

Thank mate...

Clarification of Answer by joseleon-ga on 07 Aug 2002 23:12 PDT
Hello:
  In your original question you don't say you want someone to create
code to do that, I understood you want some guide to create it by
yourself, in any way there's no problem on that, we are here to
provide you as much information we can. To create the code you want I
would need the following from you:
 
-SQL sentence to create the MySQL table you use to store your news
-Method you want to publish your news:
 RSS (Your customers must have PHP on their servers)
 HTML (Your customers must have enabled SSI on their servers)
 JS (Your customers doesn't have to have anything enabled on their
servers)

Please, choose what method you want and I will post here the code for
you.

Regards.

Request for Answer Clarification by srv-ga on 08 Aug 2002 00:17 PDT
Hi Mate,
Thank you for that...it was probably my poor explanation..sorry.
Okay well here is the code that makes the headlines on our front page
at www.iseekgof.com....half way dwon on the left-hand side.

As posted in my first question I think javascript is the only way to
go so there is no need for the other party to have PHP or SSI or
whatever...they can just use the javascript to have a simple list of 5
or 10 headlines on their site eg like a moreover.com feed.

Need the javascript to read every hour or so from an XML file on our
server thereby keeping the outgoing data lower from our side. So if
someone on the other site clicks and it has been more than an hour
since the XML file was written then it would requery the articles,
write a new XML feed and so on. Prefer not to run a cron job if
possible. Thanks again and sorry for the mixups...

My CODE
-------------

<!-- Latest Golf News -->
<?
echo "<table width=240 border=0 cellspacing=0 cellpadding=0>";

$get_news=safe_query("select * from article WHERE ArtStatus = 'Y'
ORDER BY ArtDate desc LIMIT 0,5");

while($get_rowsnews=mysql_fetch_array($get_news)){
	extract ($get_rowsnews);
	$newtime = humantime($ArtDate,"L");
	include ($_SERVER["DOCUMENT_ROOT"]."/includes/logo_switch.php"); (not
needed for this exercise)
	include ($_SERVER["DOCUMENT_ROOT"]."/includes/searchlink.php"); (see
below for code)
	
	$get_tour = safe_query("select ArtDesc from tours WHERE Artcat =
'$ArtCat'",$db);
			while ($get_all=mysql_fetch_array($get_tour)) {
				extract ($get_all);
			}
			
	//echo $sql;
	echo "<tr><td width=15 align=left valign=top><img
src=\"/images/green_sq.gif\" width=10 height=10 border=0 hspace=2
vspace=3></td><td align=left valign=top width=200><a class=matchblack
href=\"$searchlink\">".stripslashes($ArtTitle)."</a><br><span
class=bodyitl>$newtime - ";

if ($ArtTourID == "0") {
					echo "$ArtDesc";
				} else {
					echo "$ArtDesc Tour";
				}

echo "</span></td></tr>";
	echo "<tr><td width=240 colspan=2><img src=\"/images/clear.gif\"
width=1 height=4 border=0></td></tr>";
}
echo "</table>";
?>


The searchlink.php include used above is written out below...
All articles have a URL like this -
http://www.iseekgolf.com/view_articles.php/343/7/238/3/32/178/1/
So when soemone clicks on the view_articles.php and a few includes
then explode that URL and grabs the appropriate database query....

Searchlink.php include code
------------------
<?
if (!isset($week)) {
$week = date ("W",time());
}
if (!isset($page)) {
$page = "1";
}

$term = urlencode($term);
$endbit = "$ArtTourID/$ArtCat/$ArtID/$ArtBruce/$week/$ArtOld/$page/$term";
$searchlink="/view_articles.php/".$endbit;
?>

Clarification of Answer by joseleon-ga on 08 Aug 2002 01:06 PDT
Hello:
 I still need the creation SQL to recreate your news table on my local
system. Please, send it to me.

Regards.

Request for Answer Clarification by srv-ga on 08 Aug 2002 02:06 PDT
CREATE TABLE article (
  ArtID int(7) NOT NULL auto_increment,
  ArtCat int(7) NOT NULL default '0',
  ArtTourID int(7) NOT NULL default '0',
  ArtOld int(11) NOT NULL default '0',
  ArtDate datetime NOT NULL default '0000-00-00 00:00:00',
  ArtRound char(2) NOT NULL default 'N',
  ArtTitle varchar(100) NOT NULL default '',
  ArtMsg text,
  ArtView int(7) NOT NULL default '0',
  ArtRefer int(7) NOT NULL default '0',
  ArtPrint int(7) NOT NULL default '0',
  ArtComment int(7) NOT NULL default '0',
  ArtRate int(7) NOT NULL default '0',
  ArtTRate int(7) NOT NULL default '0',
  ArtBruce int(11) NOT NULL default '0',
  ArtFile varchar(255) NOT NULL default '',
  ArtStatus char(1) NOT NULL default '',
  ArtCountry char(3) NOT NULL default '',
  ArtGender char(2) NOT NULL default '',
  ArtState varchar(20) NOT NULL default 'G',
  PRIMARY KEY  (ArtID),
  KEY ArtTitle (ArtTitle)
) TYPE=MyISAM;

Clarification of Answer by joseleon-ga on 08 Aug 2002 04:41 PDT
I need the following:
-Your database connection lines, I could do it by my self, but it's
better to follow your syntax
-The include file/code for the safe_query function
-The include file/code for the humantime function
-The creation SQL for the tours table and some data to fill it
-Some data to fill the article database

Basically what I'm going to do is transform your script to dump
javascript code which will dump the table with all your news. The
users just will need to include in their pages this line:

<script type="text/javascript"
src="http://www.iseeknews.com/newsfeed.php?ly=1"></script>

Where ly is Layout so you will be able to offer several layouts.

Request for Answer Clarification by srv-ga on 08 Aug 2002 05:05 PDT
No probs...you don't need the Tours db stuff...just take that $ArtDesc
thing out...don't need it for just the headlines....

The safe_query function contains db connect stuff also...you can use
your own db properties in that...

So you are not going to query the database for these headlines
everytime are you?...the javascript should be pulling data froma
static XML file and not directly from our database.


-------------------
Safe Query Code
-------------------

<?php

	// Attempt connection to the database server
	@mysql_connect($mysql_server, $mysql_user, $mysql_pass) or
trigger_error("Cannot connect to mysql server at $mysql_server");

	// Attempt connection to the database itself
	@mysql_select_db($mysql_database) or trigger_error("Cannot find
$mysql_database database on $mysql_server");

	// Safe mysql_query function that watches for errors
	function safe_query($query) {
		$result = mysql_query($query) or trigger_error("Mysql Error
[".(mysql_error() ? mysql_error() : "Connection Failed")."]: $query");
		
		return $result;
	}
?>

-------------------------
Humantime Code
-------------------------
function humantime($dbdate,$type) {
	$time = strtotime($dbdate);
	if ($type == 'S') {
	$newtime=date("d M Y", $time);
	} elseif  ($type == 'VS'){
	$newtime=date("d M", $time);
	} elseif  ($type == 'SM'){
	$newtime=date("M Y", $time);
	} elseif ($type == 'L'){
	$newtime=date("d M Y H:i", $time);
	}
	return $newtime;
	
}

--------------------
Article Fill
--------------------
INSERT INTO article VALUES (238, 7, 343, 178, '2002-08-07 11:23:00',
'0', 'O\\\'Malley to play Buy.Com Tour event', 'Australian Peter
O\'Malley will tee it up this week in the Buy.Com Tour\'s La Salle
Bank Open in Illinois on a mission that is clearly double edged. He
will use this event both as a lead in to next week\'s PGA Championship
at Hazeltine and as a means of gaining ground on the Buy.Com Tour
money list.<br /><br />O\'Malley, who earlier in the year finished
fourth at the Buy.Com Tour\'s opening event, the Jacobs Creek Classic
in Adelaide, then the next week won the Holden Clearwater Classic in
Christchurch, had led this season\'s  Buy.Com Tour money list for
several weeks. His return to Europe however has seen his ranking slip
to fifteenth ($US117,000). A win this week and the accompanying
$US81,000, would see him return to the top two or three. That would
then leave him well placed to gain one of the fifteen cards available
at season\'s end for next year\'s USPGA Tour. Last year\'s fifteenth
placed player (Michael Long) finished the season with $US161,000 in
earnings and, despite the fact that it will likely be slightly higher
this year, it is still a very reachable target for O\'Malley.<br /><br
/>Peter Lonard has shown this season, his first in the US, that a
player with great ball striking skills and plenty of international
experience can make the grade in the US and that it is perhaps not
quite the quantum leap that has often been perceived previously.
O\'Malley is certainly a fine ball striker and does not lack
experience. Lonard has also shown that playing on quality greens week
in and week out will yield significant improvement in putting and a
similiar improvement in that department of O\'Malley\'s game, would
have him amongst the game\'s elite.<br /><br />If by chance O\'Malley
does not make it via the Buy.Com route, he still has another bite at
the cherry by gaining a start at the final stage of qualifying for the
USPGA Tour. This has come about as a result of his second placing on
the Australasian Tour money list earlier this year.<br /><br
/>O\'Malley has indicated in the past that he was keen to get his
children\'s schooling well and truly under way before he makes the
move to the US. The opportunity now presented to him and the lure of
the USPGA Tour may however be too great to let slide. One thing is for
sure, if he is able to earn his way on to the USPGA Tour, then there
is every reason to see him as yet another Australian successfully
plying his trade in the US.', 29, 0, 0, 0, 0, 0, 3,
'peter_omalley.jpg', 'Y', '', '', 'G');
INSERT INTO article VALUES (241, 18, 0, 0, '2002-08-07 12:59:43',
'NA', 'Terrey Hills back on tournament scene', 'Terrey Hills, the home
of the Canon Challenge from 1995 through 1999, has again been chosen
as the venue for a significant professional event but this time it\'s
the Australian Women\'s Open.<br /><br />The event has been staged at
the Yarra Yarra Golf Club in Melbourne for the last seven years and
whilst that has been a fine venue, the chance for Sydney fans to see
high class women\'s golf is long overdue. It is after all the national
open and it is only right that such should be on some form of rota of
courses. That is always, of course, easier said than done, especially
with the pressure of sponsorship considerations, but a move to Sydney
should be good for the event and women\'s golf in Australia.<br /><br
/>Royal Sydney was another Sydney course that had been considered for
the event but now that it is about to undergo major remodelling that
possibility is out of the question, at least in the short term. The
establishment of the event in Sydney may well mean however, that Royal
Sydney and others will also get the opportunity in the future to stage
the event.<br /><br />Terrey Hillls, a Graham Marsh designed course in
the northern suburbs of Sydney approx thirty five minutes from the
CBD, was opened in 1994 and is a private members course. It has gained
a position as one of Sydney\'s leading courses and has already proven
itself under tournament conditions.<br /><br />The event, from Feb
27th through March March 2nd 2003, will once again be co sanctioned by
both the Australian LPGA and the Ladies European Tour with the
likelihood of Karrie Webb, Rachel Teske and leading European players
participating.', 30, 0, 4, 0, 0, 0, 3, 'D', 'Y', 'AUS', 'F', 'NA');
INSERT INTO article VALUES (242, 18, 0, 0, '2002-08-07 17:13:34',
'NA', 'Linde stays in lead despite windy conditions', 'After day two
of the Mazda NSW PGA Trainee Championships at Horizons Golf Resort,
Belmont\\\'s Kurt Linde (-1) holds a narrow lead over defending
champion Danny Vera (Terrey Hills). After leading the field into day
two with a course record of five under par 67, Linde found the windy
conditions a bit more challenging today, coming home with 4 over par
to finish the day at -1 overall (143).<br /><br />Overall, scoring was
tougher on day two, with the cut being decided at +15 (159). Mark
Dixon (NSW Golf Club) and Nick Dastey from Victoria move in to the
final rounds at third and fourth respectively (146 and 147).<br /><br
/>Horizons Golf Resort trainee professionals, Luke Maga and Joel
McDougall also made the cut and will be hoping to put in a good
performance on their home course over the next two days. <br /><br
/>The trainees are competing for over AUD$30,000 in prize money,
making it the second richest event on the trainee calendar. 63 players
have made the cut and will compete in Thursday and Friday\\\'s final
rounds.<br /><br /><b>Round Two Results</b> (Par 72)<br />Kurt 
Linde	67	76	143<br />Danny  Vera	69	76	145<br />Mark 
Dixon	73	73	146<br />Nick   Dastey	73	74	147<br />Mark 
Gilson	73	73	147<br />Simon  Angliss	72	76	148<br />Steven 
Horstman	72	76	148<br />Richard  Stokes	71	78	149<br />Gavin 
Vearing	72	77	149<br />Nathan  Snell	71	79	150<br />Shannon 
Beck	74	76	150<br />Travis  Merritt	74	77	151<br />Aaron 
Townsend	74	77	151<br />Steven  Lipovas	75	76	151<br />Matthew 
Button	76	75	151<br />Steele  Denman	76	76	151<br />Allan 
Burge	77	74	151<br />Mathew  Yates	77	74	151<br />Nathan 
Stubbs	79	72	151<br />Alex  Wiffin	72	80	152<br />Konstantine 
Fondas	73	79	152<br />Ryan  Smith	74	78	152<br />Greg 
Bayley	74	79	153<br />Timothy   Steele	74	79	153<br />Lee 
Akers	75	79	154<br />Darren  Hunter	76	78	154<br />Steven 
Krause	77	77	154<br />Michael  Schneider	77	77	154<br />Graydon 
Woolridge	78	76	154<br />Bryce  MacDonald	79	75	154<br />Creigh 
Vincent	74	81	155<br />Anthony  Bergin	75	80	155<br />Danny 
Jakubowski	76	79	155<br />Luke  Altshwager	78	77	155<br />Asef 
Haddad	73	83	156<br />Christopher  Miller	74	82	156<br />Adam 
Bilbe	75	81	156<br />Anthony  Gomez	75	81	156<br />George 
Clarence	76	80	156<br />David  Sherlock	76	80	156<br />Jackson 
Chen	78	78	156<br />Bengt  Lindskog	78	78	156<br />Shane 
Cochrane	79	77	156<br />Christopher  Chilton	74	83	157<br />Adrian 
Garnett	77	80	157<br />Trevor  Tutt	81	76	157<br />Kurt 
Freeman	74	84	158<br />Matthew  Portelli	76	82	158<br />James 
Tanton	76	82	158<br />Luke   Maga	78	80	158<br />Mark 
Bryant	79	79	158<br />Raff  Toperoso	79	79	158<br />Nigel 
Orr	80	78	158<br />Josh  Lane	81	77	158<br />Scott 
Martyn	83	75	158<br />Brett  Latcham	75	84	159<br />Nick  
Porreca	77	82	159<br />Scott  Bennett	78	81	159<br />Justin 
Dickinson	78	81	159<br />David  Lawrence	80	79	159<br />Joel 
McDougal	81	78	159<br />Justin  Waring	81	78	159<br />Nicholas 
Lumley	85	74	159<br />Nigel  Durkin	74	86	160<br />Richard  Self  
77	83	160<br />Craig  Adamson	79	81	160<br />Bruce 
Alderson	80	80	160<br />Brendan  Holmes	81	79	160<br />Darryl 
Sando	81	79	160<br />Leigh  Coloe	74	87	161<br />Richard 
Johnson	75	86	161<br />Chris  Johnston	76	85	161<br />Daekeun 
Kim	78	83	161<br />Jeremey  Westaway	78	83	161<br />Brook 
Salmon	80	81	161<br />David  Patridge	82	79	161<br />Sean 
White	83	78	161<br />William  Wright	77	85	162<br />Steve 
Gannon	78	84	162<br />Alan  Cleal	80	82	162<br />Aaron 
Vatner	80	82	162<br />Joanne  Bannerman	81	81	162<br />James 
Comerford	82	80	162<br />Scott  Sando	75	88	163<br />Michael 
Brown	77	86	163<br />Robert  Nancarrow	80	83	163<br />Simon 
McPhillips	82	81	163<br />Reiner  Wratten	82	81	163<br />Dylan  
Taylor	78	86	164<br />Nicholas   Banham	79	85	164<br />Rhys 
Hillsdon	81	83	164<br />Edwin  Groot	83	81	164<br />Benjamin 
Hamilton	84	80	164<br />Nigel  Bles	77	88	165<br />Angela 
Tunchon	78	87	165<br />Luke  Cantelo	80	85	165<br />Cobie 
Campbell	83	82	165<br />Phillip  Graham	83	82	165<br />Perrin 
Gleeson	87	78	165<br />Brett  Jackson	78	88	166<br />Ben 
Marron	79	88	167<br />James  Barlow	83	84	167<br />Katherine 
Leyshon	77	91	168<br />Jake  Nagle	81	87	168<br />David 
Long	86	82	168<br />Zied  Bechara	81	88	169<br />Phillip 
Bowran	86	83	169<br />Brad  Evans	79	91	170<br />Daniel 
Sheaffe	84	87	171<br />Neil  Rolfe	91	81	172<br />Christian 
McGill	81	DISQ	DISQ<br />Ian  Maynard	82	DISQ	DISQ<br />Ben 
Maroney	90	DISQ	DISQ<br />Shane  Dunn	DISQ	DISQ	 DISQ<br />', 27, 0,
0, 0, 0, 0, 4, 'D', 'Y', 'AUS', 'M', 'NSW');
INSERT INTO article VALUES (243, 15, 712, 404, '2002-08-07 18:50:21',
'NA', '2002 Vic Open moves to Portsea and Sorrento', 'The 2002
Victorian Open Golf Championship is to be played in a new format at
Sorrento and Portsea Golf Clubs over the period 24-27 October.<br
/><br />The event has been re-structured to include a \\"National
Pro-Am\\" component in which sponsor guests will be teamed and playing
with the tournament professionals for the opening two days.<br /><br
/>Half the field will play at Portsea and half at Sorrento on the
opening day and then rotate to the other course for the second round.
The National Pro-Am component will conclude after two rounds and the
Vic Open cut will be made to leave 60 professionals plus ties
contesting the Saturday and Sunday final rounds at Sorrento Golf Club.
The event carries PGA Tour Order-of-Merit status and a minimum
prizemoney of $100,000.<br /><br />Announcing the new format, Mr. Dick
Kirby, VGA President said \\"Innovation was needed in the Vic Open to
secure its position with sponsors. The National Pro-Am component
provides an opportunity for companies and groups of all sizes to take
a role in this prestigious Championship. We have some very attractive
sponsor opportunities at relatively low cost. Sorrento and Portsea
both have outstanding facilities and we expect enthusiastic response
from this opportunity to showcase two special golf courses to the PGA
Tour professionals and the golfing public.\\"<br /><br />PGA Tour
Chairman, Wayne Grady said, \\"We respect the great tradition of the
Vic Open. We are pleased to support the Victorian Golf Association in
their desire to give the event a new face and a lift.\\"', 25, 0, 0,
0, 3, 1, 4, 'laycock.jpg', 'Y', '', '', 'G');
INSERT INTO article VALUES (246, 21, 0, 0, '2002-08-08 16:15:41',
'NA', 'Leading Australasians miss out on US Amateur', 'The US Amateur
Chanpionship, to be played at Oakland Hills in Michigan from August
19th, will be missing several leading Australasians following the
final qualifying at venues around the country this past week.<br /><br
/>The two leading ranked Australians Andrew Buckle and Simon Nash
missed as did New Zealanders Tim Wilkinson and Eddie Lee. New South
Wales golfer Richard Swift was the leading qualifier at his venue in
Maryland tying for first with number two ranked US Amateur Brian
Quackenbush and gaining one of only three spots available there. He
along with Geoff Lound, will be the only two Australians to take their
place in the field. Lound qualified at his venue in Illinois.<br /><br
/>Buckle has proabably come to the end of his teether after three
months on the road and it may be that he is looking forward to a break
before he heads to Malaysia later this year to represent Australia in
the World Teams event there. Another Australian representative, Adam
Groom, chose not to play the qualifying instead heading for home<br
/><br />New Zealander Brad Heaven, who did so well last week at the
Western Amateur making it through to the matchplay, will have an
anxious wait as he has an alternate spot.<br /><br />A reflection on
the strength of player having to go through the qualifying process is
that even last week\'s Western Amateur champion John Klauk was forced
to do so. He made it .', 7, 0, 0, 0, 0, 0, 3, 'D', 'Y', 'INT', 'G',
'NA');
INSERT INTO article VALUES (245, 15, 862, 153, '2002-08-06 14:01:53',
'NA', 'Els and Goosen to play 2003 Johnnie Walker', 'The 32-year-old
has an impressive history in the majors winning the US Open in 1994
and 1997 as well as the 2002 Open Championship. He also finished
runner-up in three of the four major championships in 2000. After a
top four finish in the 2002 Johnnie Walker Classic, Els will be aiming
to win his second Johnnie Walker title next February 2003, having won
at Hope Island in Queensland in 1997. <br /><br />The return to Lake
Karrinyup Country Club in 2003 marks the first time in the history of
the Johnnie Walker Classic that the event has returned to the same
venue in consecutive years.<br /><br />Retief Goosen, a friend and
compatriot of Els, will welcome the return after dominating the event
last January. He took a stranglehold on the tournament during the
third round firing a course-record 63 to lead by a massive 13 shots
entering the final day before easing up to win by eight. <br /><br
/>Goosen has been a prominent mover in the world rankings over the
past year and won his first major title - the US Open - in 2001.
Goosen went on to clinch the 2001 European Tour\\\'s Volvo Order of
Merit after victories at the Scottish Open and at the Telefonica Open
de Madrid. <br /><br />Goosen\\\'s fine form in 2002 has enabled him
to win on three different continents. He took the Dimension Data
Pro-Am in South Africa in February straight after winning in Perth and
then won the BellSouth Classic in America before finishing runner-up
to Tiger Woods at The Masters. Goosen, 33, has also finished second on
two other occasions this season - at the Dunhill Championship in South
Africa and more recently at the 2002 Smurfit European Open in Dublin.
<br /><br />The Johnnie Walker Classic, jointly owned by Guinness UDV
and IMG is tri- sanctioned by the European, Australasian and Asian
Tours. It is the richest event on the Australasian Tour and in its 11
year history has always attracted the world\\\'s best golfers. First
staged in Hong Kong the event has been played in six different
countries over nine different golf courses and has been won by Tiger
Woods twice, Nick Faldo twice, Greg Norman, Fred Couples, Ian Woosnam,
Ernie Els, Michael Campbell and this year\\\'s winner Retief Goosen.',
0, 0, 0, 0, 0, 0, 4, 'retief_goosen.jpg', 'Y', '', '', 'G');

Request for Answer Clarification by srv-ga on 08 Aug 2002 15:50 PDT
CREATE TABLE article (
  ArtID int(7) NOT NULL auto_increment,
  ArtCat int(7) NOT NULL default '0',
  ArtTourID int(7) NOT NULL default '0',
  ArtOld int(11) NOT NULL default '0',
  ArtDate datetime NOT NULL default '0000-00-00 00:00:00',
  ArtRound char(2) NOT NULL default 'N',
  ArtTitle varchar(100) NOT NULL default '',
  ArtMsg text,
  ArtView int(7) NOT NULL default '0',
  ArtRefer int(7) NOT NULL default '0',
  ArtPrint int(7) NOT NULL default '0',
  ArtComment int(7) NOT NULL default '0',
  ArtRate int(7) NOT NULL default '0',
  ArtTRate int(7) NOT NULL default '0',
  ArtBruce int(11) NOT NULL default '0',
  ArtFile varchar(255) NOT NULL default '',
  ArtStatus char(1) NOT NULL default '',
  ArtCountry char(3) NOT NULL default '',
  ArtGender char(2) NOT NULL default '',
  ArtState varchar(20) NOT NULL default 'G',
  PRIMARY KEY  (ArtID),
  KEY ArtTitle (ArtTitle)
) TYPE=MyISAM;

Clarification of Answer by joseleon-ga on 08 Aug 2002 23:08 PDT
>So you are not going to query the database for these headlines
>everytime are you?...the javascript should be pulling data froma
>static XML file and not directly from our database.
And where is the performance gain with the XML method?. I mean, if the
client cannot have PHP installed on their system, must make everytime
a request to your server. Where is the performance gain between
resquest a PHP file which transform an XML file and dumps out
Javascript code and request a PHP file which dumps out Javascript code
from the database information?. You could say less database
connections, but I will say to create the XML file which resides on
your server you must create a cron job to produce it at an specified
interval or let the PHP script which ask for the XML file to manage
when must generate the XML file storing when it was the last request.
I will do what you want, there's no problem at all, but I suggest you
to create a single PHP file which manages all.

Regards.

Request for Answer Clarification by srv-ga on 08 Aug 2002 23:59 PDT
Ahhh okay...well let's do it your way and see how we go I spose....As
long as the database isn't getting hammered unnessarily all the time
then it is fine. I just want it done the most effcient way...if that
is a cron job and XML then I will sort that out ...if it is the PHP
way then let's do it that way..

Thanks and hear from you soon..
Jason

Clarification of Answer by joseleon-ga on 09 Aug 2002 07:00 PDT
Hello:
  Here it is your code to publish your news to other sites without
force your customers to have PHP:
  
//****************    newsfeed.php
<?php

 $mysql_server='localhost';
 $mysql_user='root';
 $mysql_pass='root';
 $mysql_database='iseekgolf';
 
 // Attempt connection to the database server 
 @mysql_connect($mysql_server, $mysql_user, $mysql_pass) or
trigger_error("Cannot connect to mysql server at $mysql_server");
 
 // Attempt connection to the database itself 
 @mysql_select_db($mysql_database) or trigger_error("Cannot find
$mysql_database database on $mysql_server");
 
 // Safe mysql_query function that watches for errors 
 function safe_query($query) 
 { 
  	$result = mysql_query($query) or trigger_error("Mysql Error
[".(mysql_error() ? mysql_error() : "Connection Failed")."]: $query");
  	return $result; 
 } 
 
function humantime($dbdate,$type) 
{ 
	$time = strtotime($dbdate); 
	if ($type == 'S') 
	{ 
 		$newtime=date("d M Y", $time); 
 	} 
 	elseif  ($type == 'VS')
 	{ 
 		$newtime=date("d M", $time); 
 	} 
 	elseif  ($type == 'SM')
 	{ 
 		$newtime=date("M Y", $time); 
 	} 
 	elseif ($type == 'L')
 	{ 
 		$newtime=date("d M Y H:i", $time); 
 	} 
 	return $newtime; 
}  


echo "function writeNews() {\n"; 

echo "document.write('<'+'link rel=\"stylesheet\" type=\"text/css\"
href=\"http://www.iseekgolf.com/css/iseek.css\" />');";

echo "document.write('<table width=240 border=0 cellspacing=0
cellpadding=0>');\n";
 
$get_news=safe_query("select * from article WHERE ArtStatus = 'Y'
ORDER BY ArtDate desc LIMIT 0,5");

while($get_rowsnews=mysql_fetch_array($get_news))
{ 
 	extract ($get_rowsnews); 
 	$newtime = humantime($ArtDate,"L"); 
  	include ("searchlink.php"); 

  
 	echo "document.write('<tr><td width=15 align=left valign=top><img
src=\"http://www.iseekgolf.com/images/green_sq.gif\" width=10
height=10 border=0 hspace=2 vspace=3>');\n";

        //echo "document.write('<A
href=\"$searchlink\">dddd</A>');\n";
 	echo "document.write('</td><td align=left valign=top width=200><a
class=matchblack href=\"http://www.iseekgolf.com$searchlink\">');\n";
 	echo "document.write('$ArtTitle</a><br>');\n";
 	
 	
 	echo "document.write('<span class=bodyitl>$newtime');\n";
 
	echo "document.write('</span></td></tr>');\n"; 
 	echo "document.write('<tr><td width=240 colspan=2><img
src=\"http://www.iseekgolf.com/images/clear.gif\" width=1 height=4
border=0></td></tr>');\n";
 	
} 

echo "document.write('</table>');\n"; 
echo "}\n"; 
echo "writeNews();\n"; 

?>  
//****************    test.html
<html>
<head>
<title>Your test page</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script type="text/javascript"
src="http://www.iseekgolf.com/newsfeed.php"></script>
</body>
</html>


I have used fully qualified URLs to point to your website, images and
CSS sheet are taken from there. You just have to copy newsfeed.php in
your root directory and your customers will be able to include your
news using this line:

<script type="text/javascript"
src="http://www.iseekgolf.com/newsfeed.php"></script>

After that you can modify the script to include layouts or whatever
you want.

I hope this is what were looking for.

Regards.

Request for Answer Clarification by srv-ga on 11 Aug 2002 07:45 PDT
Hi mate
thanks for the script but it doesn't seem to
work...http://www.iseekgolf.com/test_feed.html

Jason

Clarification of Answer by joseleon-ga on 12 Aug 2002 00:14 PDT
Hello:
  Your link works for me, look at this screenshot:

http://www.qadram.com/iseek.gif

What problem do you have? What error message do you get? Could you
post a screenshot of your problem?

Regards.

Request for Answer Clarification by srv-ga on 12 Aug 2002 01:14 PDT
Wow...that is really bizarre. All day it has just been showing a blank
page....I have no idea why it is working now but I won't ask questions
:))

Thank you very much..that is exactly what I wanted...perfect!

Clarification of Answer by joseleon-ga on 12 Aug 2002 05:00 PDT
Nice to hear that, I hope you've found useful this Google service and use it again!

Regards.
P.S. Don't forget to rate this question ;-)

Request for Answer Clarification by srv-ga on 14 Aug 2002 00:17 PDT
Hi Mate,
Problem...I haven't touched the code and now the same thing is
happening again...it is just showing a blank page at
http://www.iseekgolf.com/test_feed.html...very strange indeed...works
one time and not the other! I don;t want to go offering the code out
and have it not work.

Thanks

Clarification of Answer by joseleon-ga on 14 Aug 2002 01:24 PDT
Hello:
 
You just have to add this lines:          
         $ArtTitle=str_replace("\'","'",$ArtTitle);
         $ArtTitle=str_replace("'","\'",$ArtTitle);         
         
before this one on your script:
         echo "document.write('$ArtTitle</a><br>');\n";         
         
Why?
 In the creation SQL you sent me the ' sign, was stored on database as
\', so there's no problem when you output this as javascript, but in
the news you are dumping right now, the ' is stored on database as ',
so we must first convert it to \'.

The lines you must add, first changes all the \' to single ' and then
all the single ' to \', this way you can have on your database article
titles with both \' and '.

That's the reason of intermitent faults, depending on the articles you
have, it worked or not. I suggest you to use the Mozilla JavaScript
console to debug that kind of problems. Look at:

http://www.qadram.com/error.gif

To see the error.

I hope this solves all your problems.

Regards.

Request for Answer Clarification by srv-ga on 14 Aug 2002 01:55 PDT
Aaah....that certainly makes sense!....I'm not sure why those articles
are going in without the escaping..will check..

Thanks again for the prompt reply

Clarification of Answer by joseleon-ga on 14 Aug 2002 04:19 PDT
Hello:
  And again thanks for use Google Answers! ;-)

Regards.
srv-ga rated this answer:4 out of 5 stars
Great answer....ended up with exactly what I needed...Thanks!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy