DanielAttard
asked on
Pass variable to PHP file which creates XML
The code below selects all records from the specified table, and outputs the results to XML. I use the following constructor in HTML to create a dataset from these records:
var myDataset = new Spry.Data.XMLDataSet("xml/ myTable.ph p", "root/record");
My question is, how can I pass a variable from the constructor line into the PHP file which will act as a filter? What if I only want a subset of records from the underlying table? Thanks for your help.
var myDataset = new Spry.Data.XMLDataSet("xml/
My question is, how can I pass a variable from the constructor line into the PHP file which will act as a filter? What if I only want a subset of records from the underlying table? Thanks for your help.
<?php
$hostname_conn = "localhost";
$database_conn = "myDB";
$username_conn = "root";
$password_conn = "root";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
mysql_select_db($database_conn, $conn);
//$query_rsAll = "SELECT * FROM myTable";
$rsAll = mysql_query($query_rsAll, $conn) or die(mysql_error());
$row_rsAll = mysql_fetch_assoc($rsAll);
$totalRows_rsAll = mysql_num_rows($rsAll);
// Send the headers
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
?>
<?php echo('<?xml version="1.0" encoding="utf-8"?>'); ?>
<root>
<?php if ($totalRows_rsAll > 0) { // Show if recordset not empty ?>
<?php do { ?>
<record>
<?php foreach ($row_rsAll as $column=>$value) { ?>
<<?php echo $column; ?>><![CDATA[<?php echo $row_rsAll[$column]; ?>]]></<?php echo $column; ?>>
<?php } ?>
</record>
<?php } while ($row_rsAll = mysql_fetch_assoc($rsAll)); ?>
<?php } // Show if recordset not empty ?>
</root>
<?php
mysql_free_result($rsAll);
?>
ASKER
Ok thanks. I'll take a look and let you know how I make out. Just getting started with DW CS4. It's all new to me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to decide how the variable is going to be passed to the script. You then re-do the Dreamweaver Recordset Wizard and choose the appropriate filter option. DW will build the code for you.