Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/purvgwtw/public_html/tutorials/common.php on line 7
PHP XML Data Provider
Sponsered Links
Categories
Sponsered Links

PHP XML Data Provider

This is a very simple data provider for the cascading dropdown example. A *real* data provider would most likely connect to a database, use xslt and implement some level of security.

<?php

    // This is a very simple data provider for the cascading dropdown
    // example. A *real* data provider would most likely connect to
    // a database, use xslt and implement some level of security.

    Header("Content-type: text/xml");
    // get query string params
    $filter = $_GET['filter'];
    $xml = '';
    $iscountry = 1;
    // build xml content for client JavaScript


    include 'dbcon.php';

    mysql_select_db($database, $conn);
    $query  = "SELECT * from subcategory where cat_id = '$filter'";
    $result = mysql_query($query);
    while($row = mysql_fetch_assoc($result))
    {
        if ($iscountry == 1)
        {
        $xml = $xml . '<continent name="' . $row['category'] . '">';
        }
       
        $xml = $xml . '<country id="' . $iscountry . '">' . $row['subcategory'] . '</country>';
        $iscountry = $iscountry + 1;
    }   
    $xml = $xml . '</continent>';
   
    if ($iscountry == 1)
    {
        $xml = $xml . '<continent name="none">';
        $xml = $xml . '<country id="0">no countries found</country>';
        $xml = $xml . '</continent>';
    }

    // send xml to client
    echo( $xml );
?>

Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2014 PURVACOMPUTERS.COM All Right Reserved