•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 425,982 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,653 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3869 | Replies: 34 | Solved
![]() |
hi,
The problem was not with AJAX or PHP code, but it was with the xml generation. I have included the modified code. I have added a root element for the XML.
This solves your problem.
The problem was not with AJAX or PHP code, but it was with the xml generation. I have included the modified code. I have added a root element for the XML.
<?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'];
//Connect to mysql server
$link = @mysql_connect("localhost","root","");
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = @mysql_select_db("dropdown");
if(!$db) {
die("Unable to select database");
}
//Create query of Faculty
$qryDepartment = "
SELECT dep_id, dep_name, tbl_faculty.f_id, f_name
FROM tbl_department, tbl_faculty
WHERE tbl_department.f_id = tbl_faculty.f_id
AND f_name = '$filter'
";
$resultDepartment = mysql_query($qryDepartment);
// build xml content for client JavaScript
$xml = "<mxml>";
while($department = mysql_fetch_array($resultDepartment)){
$fn = $department['f_name'];
$di = $department['dep_id'];
$xml = $xml . '<faculty name="'.$fn.'">';
$xml = $xml . '<department id="'.$di.'">'.$department["dep_name"].'</department>';
$xml = $xml . '</faculty>';
}
$xml = $xml . "</mxml>";
// send xml to client
echo( $xml );
?>This solves your problem.
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
•
•
Join Date: Aug 2007
Posts: 167
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for the attachment,
BUT I don't know why the data in location.sql, can not be inerted into MySQL, and also with open it with notepad, or notepad++, the data is not readable.
Can you please post me the encoding of that, I mean localtion.sql.
Thanks
BUT I don't know why the data in location.sql, can not be inerted into MySQL, and also with open it with notepad, or notepad++, the data is not readable.
Can you please post me the encoding of that, I mean localtion.sql.
Thanks
Last edited by tanha : Jul 8th, 2008 at 9:12 am.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Aug 2007
Posts: 167
Reputation:
Rep Power: 0
Solved Threads: 0
yeah.
It is all right, JUST I deleted the cookies from the browsers, and now it is working well.
I mean, if you the faculty exist in the first drop-down, and there is no department for it into the tbldepartment, it shows nothing, and then later on if you add departments for that faculty, and you select again that faculty it does not display the related departments, untill you delete the cookies from the history.
I don't know actually why AJAX do like this?
It is all right, JUST I deleted the cookies from the browsers, and now it is working well.
I mean, if you the faculty exist in the first drop-down, and there is no department for it into the tbldepartment, it shows nothing, and then later on if you add departments for that faculty, and you select again that faculty it does not display the related departments, untill you delete the cookies from the history.
I don't know actually why AJAX do like this?
Last edited by tanha : Jul 8th, 2008 at 10:33 am.
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Publishing php/mysql on Apache website
- Next Thread: How many queries can be preformed in one click?



Linear Mode