<form name="location" method="post" action="/phpsqlsearch_genxml1.php" enctype="text/plain" id="Form1">
<input type="submit" id="Button1" name="Button1" value="Submit" style="position:absolute;left:164px;top:47px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:0">
<select name="location" size="1" id="Combobox1" style="position:absolute;left:31px;top:47px;width:96px;font-family:Courier New;font-size:16px;z-index:1" title="location">
<option>Maine</option>
<option>Florida</option>
</select>
</form>
and this PHP to process and return the xml needed for my map API
if I change $query = "SELECT * FROM markers WHERE location='$location'"; to $query = "SELECT * FROM markers WHERE location='Maine'";
it works fine but I need it to return the results from the form . any help would be greatly appreciated
Code: Select all
<?php
require("databaseinfo.php");
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// 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
$location = $_POST['location'];
$query = "SELECT * FROM markers WHERE location='$location'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("location", $row['location']);
}
echo $dom->saveXML();
?>