HakonHoy
10-03-2006, 05:31 PM
I have a news website where I want other websites/partners to be able to display headlines from. So I tought of a solution where I use php and javascript so that they can be able to have the news headlines on their website.
Php:
strCode='<?php
# see_rec.php
# include file
$db="dbname";
$connect = mysql_connect('localhost', 'user', 'pass');
if (! $connect)
die("Couldn't connect to MySQL");
mysql_select_db($db , $connect) or die("Select Error: ".mysql_error());
$query="SELECT news FROM newstable ORDER BY date DESC LIMIT 0, 5";
$results = mysql_query($query)
or die(mysql_error());
while ($row = mysql_fetch_array($results)) {
extract($row);
echo "$news";
}
mysql_close($connect);
?>'
The Javascript on their website:
<script language="JavaScript"> var strCode = '';</script>
<script src="http://www.ontheminute.com/webmaster/newsbox/op/realmadrid.php"></script>
<script language="JavaScript">document.write(strCode);</script>
Shouldn't this work? I have tried it but it doesn't :/ If anyone can help me with this solution or have suggestions of other solutions to my problem.. Please help
Php:
strCode='<?php
# see_rec.php
# include file
$db="dbname";
$connect = mysql_connect('localhost', 'user', 'pass');
if (! $connect)
die("Couldn't connect to MySQL");
mysql_select_db($db , $connect) or die("Select Error: ".mysql_error());
$query="SELECT news FROM newstable ORDER BY date DESC LIMIT 0, 5";
$results = mysql_query($query)
or die(mysql_error());
while ($row = mysql_fetch_array($results)) {
extract($row);
echo "$news";
}
mysql_close($connect);
?>'
The Javascript on their website:
<script language="JavaScript"> var strCode = '';</script>
<script src="http://www.ontheminute.com/webmaster/newsbox/op/realmadrid.php"></script>
<script language="JavaScript">document.write(strCode);</script>
Shouldn't this work? I have tried it but it doesn't :/ If anyone can help me with this solution or have suggestions of other solutions to my problem.. Please help
