Hi, thank you for your effort :)))
Here is what I have as of now: (The table below is there as a help reference to show exactly what is in the mysql database.)
http://tinyurl.com/6a76aek
The HTML is structured like this:
[php]
<?php
$username="****";
$password="*****";
$database="****";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$query=“SELECT * FROM markers”;
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
?>
Name:
Address:
Type:
Name |
Address |
Type |
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"Name");
$f2=mysql_result($result,$i,"Address");
$f3=mysql_result($result,$i,"Type");
?>
<?php echo $f1; ?> |
<?php echo $f2; ?> |
<?php echo $f3; ?> |
<?php
$i++;
}
?>[/php]
And get_xml2.php that the information is sent to looks like this:
[php]<?php
require(“db_access.php”);
function parseToXML($htmlStr)
{
$xmlStr=str_replace(’<’,’<’,$htmlStr);
$xmlStr=str_replace(’>’,’>’,$xmlStr);
$xmlStr=str_replace(’"’,’"’,$xmlStr);
$xmlStr=str_replace("’",’’’,$xmlStr);
$xmlStr=str_replace("&",’&’,$xmlStr);
return $xmlStr;
}
$Name=$_POST[‘Value1’];
$Address=$_POST[‘Value2’];
$Type=$_POST[‘Value3’];
// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die('Not connected : ’ . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can’t use db : ’ . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT Name, Address, Type FROM markers WHERE Name = ’ .$Name. ’ AND Address = ’ .$Address. ’ AND type = ’ .$Type. ’ ";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ’ . mysql_error());
}
header(“Content-type: text/xml”);
// Start XML file, echo parent node
echo ‘’;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo ‘name="’ . parseToXML($row[‘name’]) . '" ';
echo ‘address="’ . parseToXML($row[‘address’]) . '" ';
echo ‘lat="’ . $row[‘lat’] . '" ';
echo ‘lng="’ . $row[‘lng’] . '" ';
echo ‘type="’ . $row[‘type’] . '" ';
echo ‘/>’;
}
// End XML file
echo ‘’;
?>[/php]
I want, when I insert for example “restaurant” in the type field, to return all rows with the type=restaurant. When I do that, the xml file returned is empty.