hokage
07-01-2008, 08:44 AM
i have some problem..it's make me curious...
i want to try to connect OL with MySql Through PHP..
here is the laszlo code
<canvas width="100%" height="100%">
<dataset name="dset" src="http://localhost/lightforum/lihatberita.php" request="true" type="http"/>
<simplelayout axis="y"/>
<view x="200" name="myTable">
<simplelayout axis="y"/>
<view name="rowOfData" datapath="dset:/phonebook/contact">
<simplelayout axis="x"/>
<text datapath="@title"/>
<text datapath="@message"/>
<text datapath="@postDate"/>
</view>
</view>
</canvas>
.
and here is php code for lihatberita.php
<?php
require_once('db_config.inc.php'); // connect mysql db through $dbh
$query = "SELECT * FROM berita";
$result = mysql_query($query,$dbh);
$_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .= "<phonebook>\r\n";
while ($row = mysql_fetch_array($result)) {
$_xml .= "\t<contact title=\"" . $row['title'] . "\" message=\"" . $row['message'] . "\" postDate=\"" . $row['postDate'] . "\" />\r\n";
}
$_xml .= "</phonebook>\r\n";
echo $_xml;
mysql_free_result($result);
mysql_close($dbh) or die ("Could not close connection to database!");
?>
it work, i see the database in mysql.. but somehow, message that have html tag cant be shown. i wonder why ?
please help me...
i want to try to connect OL with MySql Through PHP..
here is the laszlo code
<canvas width="100%" height="100%">
<dataset name="dset" src="http://localhost/lightforum/lihatberita.php" request="true" type="http"/>
<simplelayout axis="y"/>
<view x="200" name="myTable">
<simplelayout axis="y"/>
<view name="rowOfData" datapath="dset:/phonebook/contact">
<simplelayout axis="x"/>
<text datapath="@title"/>
<text datapath="@message"/>
<text datapath="@postDate"/>
</view>
</view>
</canvas>
.
and here is php code for lihatberita.php
<?php
require_once('db_config.inc.php'); // connect mysql db through $dbh
$query = "SELECT * FROM berita";
$result = mysql_query($query,$dbh);
$_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .= "<phonebook>\r\n";
while ($row = mysql_fetch_array($result)) {
$_xml .= "\t<contact title=\"" . $row['title'] . "\" message=\"" . $row['message'] . "\" postDate=\"" . $row['postDate'] . "\" />\r\n";
}
$_xml .= "</phonebook>\r\n";
echo $_xml;
mysql_free_result($result);
mysql_close($dbh) or die ("Could not close connection to database!");
?>
it work, i see the database in mysql.. but somehow, message that have html tag cant be shown. i wonder why ?
please help me...