RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 5954 | Replies: 34 | Solved | Thread Tools  Display Modes
Reply
Join Date: Jun 2008
Location: Delhi
Posts: 119
Reputation: vicky_rawat is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 15
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #11  
Jul 8th, 2008
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.


<?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.
Reply With Quote  
Join Date: Aug 2007
Posts: 183
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #12  
Jul 8th, 2008
Thanks vicky_rawat, for the reply,
BUT it is still not working, I don't know what to do?
Reply With Quote  
Join Date: Aug 2007
Posts: 183
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #13  
Jul 8th, 2008
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
Originally Posted by Shanti Chepuru View Post
Check these attachments..
These are very usefull for you..

The dropdown works on both php and ajax..
Check out..
Thank
Shanti
Last edited by tanha : Jul 8th, 2008 at 10:12 am.
Attached Images
File Type: jpg untitled.JPG (111.7 KB, 10 views)
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Cascading Dropdown list with (AJAX, PHP)

  #14  
Jul 8th, 2008
Originally Posted by tanha View Post
Thanks vicky_rawat, for the reply,
BUT it is still not working, I don't know what to do?


I tried vicky_rawat's code and it works perfectly fine..
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*
Reply With Quote  
Join Date: Aug 2007
Posts: 183
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #15  
Jul 8th, 2008
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?
Last edited by tanha : Jul 8th, 2008 at 11:33 am.
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 993
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 90
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #16  
Jul 9th, 2008
You just copy and paste the content which is in notepad into your mysql query...
Reply With Quote  
Join Date: Aug 2007
Posts: 183
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #17  
Jul 9th, 2008
When I copy and paste the contents in mysql query, then the data inserted, but not readable.
WHY like this? WHAT I should I do ?
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 993
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 90
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #18  
Jul 9th, 2008
Tanha...
Tel me what mysql version you are using...
Is it phpmyadmin or not...
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 993
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 90
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #19  
Jul 9th, 2008
These what i attatched are finely working...Check out once again...
Reply With Quote  
Join Date: Aug 2007
Posts: 183
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #20  
Jul 9th, 2008
I am using:
MySQL 5.0.51b
phpMyAdmin 2.11.7

and I used the the import, and also the copy and paste in phpmyadmin, but still the inserted data is not readable?

I checked it many times, and I tried opening the file, with notepad, notepad++, and dream viewer, not readable there.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the PHP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:40 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC