Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
Share
LinkBack Thread Tools
Old 02-10-2013, 11:54 PM   #1
Razibur Rahman
 
Join Date: Apr 2012
Location: Dhaka
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default PHP problem - Help needed

Hello programmers,

I am developing a web page. now my problem is...

I am working with relation database. I have a category and subcategory option and so in my form there are 2 list one category menu list and subcategory menu list.

So I want to know that if I select a category from a list immediately show all subcategory of that selected category from database.

Waiting for solution.
rrahman is offline   Reply With Quote
Old 02-11-2013, 01:28 AM   #2
Software Product Creator
War Room Member
 
SteveSRS's Avatar
 
Join Date: May 2012
Location: NL & Peru & USA
Posts: 430
Blog Entries: 5
Thanks: 41
Thanked 146 Times in 83 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Default Re: PHP problem - Help needed

If you have the proper relations set and your db is relational yes it will...
however you're a bit vague.. you might wanna include some more info like which database you are working with.

SteveSRS is online now   Reply With Quote
Old 02-11-2013, 03:42 AM   #3
Active Warrior
 
Join Date: Oct 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
Default Re: PHP problem - Help needed

SteveSRS is right, your problem is not very clear.

Do you want to know what DB structure to use for categories/subcategories and the way of relations between them,
or do you want a solution for subcategories display on category selection (what's the DB structure then for categories and subcategories),
or you might want to select a category submit and get a subcategory list...
viescripts is offline   Reply With Quote
Old 02-11-2013, 07:42 AM   #4
Senior Warrior Member
War Room Member
 
SteveJohnson's Avatar
 
Join Date: Apr 2007
Location: Caldwell, Idaho, USA.
Posts: 2,037
Thanks: 576
Thanked 1,385 Times in 843 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via Yahoo to SteveJohnson
Default Re: PHP problem - Help needed

What you'll need to do is some behind the scenes javascript. Disable the subcat dropdown so that people are forced to choose top-level cat first.

When first cat is chosen, use AJAX to query for subcats of the chosen category. Or, if you don't want to use AJAX, you can build select boxes for all of the subcats, grouped by category parent, with css display:none. Then use onchange event on the main cat select to turn on the proper subcat select section.
SteveJohnson is offline   Reply With Quote
Old 02-11-2013, 07:56 AM   #5
Razibur Rahman
 
Join Date: Apr 2012
Location: Dhaka
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default Re: PHP problem - Help needed

Quote:
Originally Posted by viescripts View Post
SteveSRS is right, your problem is not very clear.

Do you want to know what DB structure to use for categories/subcategories and the way of relations between them,
or do you want a solution for subcategories display on category selection (what's the DB structure then for categories and subcategories),
or you might want to select a category submit and get a subcategory list...
I am working with Relation Database... like this:

Subcategory
Parent categoty (id) > category (id).

And I want when a user click or select a category from category list, all the subcategory of that selected category will display on sub category menu...

Similar with directory link submitted system.. someone click on main category after that subcategory option display.

Hope my problem is now clear.
rrahman is offline   Reply With Quote
Old 02-11-2013, 12:22 PM   #6
Social Apps Made Easy
War Room Member
 
FirstSocialApps's Avatar
 
Join Date: Aug 2012
Location: Mooresville, NC
Posts: 918
Thanks: 223
Thanked 252 Times in 209 Posts
Social Networking View Member's FaceBook Profile 
Default Re: PHP problem - Help needed

I think what your saying is that you have a drop down with categories and then want the sub categories to show based on the category selection.

There are a couple ways to do this one is with JQUERY
Chained Selects jQuery Plugin

Another would be with PHP/JS ala AJAX

FirstSocialApps is offline   Reply With Quote
Old 02-20-2013, 01:07 AM   #7
Razibur Rahman
 
Join Date: Apr 2012
Location: Dhaka
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default Re: PHP problem - Help needed

Quote:
Originally Posted by FirstSocialApps View Post
I think what your saying is that you have a drop down with categories and then want the sub categories to show based on the category selection.

There are a couple ways to do this one is with JQUERY
Chained Selects jQuery Plugin

Another would be with PHP/JS ala AJAX
Can you please help me to get data from mysql database in below script...? I mean there are custom/fixed value in <select> <option>.. I want to get value from my database in option field and run that script

HTML Code:
<!DOCTYPE html> 
<html>
<head>
<script type="text/javascript">

function populate(s1,s2){    
var s1 = document.getElementById(s1);    
var s2 = document.getElementById(s2);    
s2.innerHTML = "";    
if(s1.value == "Chevy"){       
 var optionArray = ["|","camaro|Camaro","corvette|Corvette","impala|Impala"];    } else if(s1.value == "Dodge"){       
var optionArray = ["|","avenger|Avenger","challenger|Challenger","charger|Charger"];    } else if(s1.value == "Ford"){        
var optionArray = ["|","mustang|Mustang","shelby|Shelby"];    }    
for(var option in optionArray){        
var pair = optionArray[option].split("|");        
var newOption = document.createElement("option");        
newOption.value = pair[0];        
newOption.innerHTML = pair[1];        
s2.options.add(newOption);    }
}
</script>
</head>
<body>
<h2>Choose Your Car</h2>
<hr />
Choose Car Make:
<select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">  
<option value=""></option>  
<option value="Chevy">Chevy</option>  
<option value="Dodge">Dodge</option>  
<option value="Ford">Ford</option>
</select>
<hr />
Choose Car Model:
<select id="slct2" name="slct2"></select>
<hr />
</body>
</html>
rrahman is offline   Reply With Quote
Old 03-20-2013, 01:42 PM   #8
Active Warrior
Registered Member
 
Join Date: Feb 2013
Posts: 58
Thanks: 3
Thanked 8 Times in 8 Posts
Default Re: PHP problem - Help needed

Quote:
Originally Posted by SteveJohnson View Post
What you'll need to do is some behind the scenes javascript. Disable the subcat dropdown so that people are forced to choose top-level cat first.

When first cat is chosen, use AJAX to query for subcats of the chosen category. Or, if you don't want to use AJAX, you can build select boxes for all of the subcats, grouped by category parent, with css display:none. Then use onchange event on the main cat select to turn on the proper subcat select section.
This is right, use AJAX, they have a control tool kit for .NET which makes this really easy. But since your using php, youll have to find a version for that.

Basically youll need a SQL query with a where clause controlled by the first drop down. I can show you how to do it in ASP.NET and MSSQL. What are you on a Windows or Unix based server? What is your database MSSQL, MySQL, ...?

Last edited by kevintb7; 03-20-2013 at 01:45 PM. Reason: added more info
kevintb7 is offline   Reply With Quote
Old 03-23-2013, 02:50 PM   #9
Web Developer
 
Join Date: Mar 2011
Location: Ontario, Canada
Posts: 192
Thanks: 16
Thanked 25 Times in 24 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Default Re: PHP problem - Help needed

I'd say if you're not too deep in the project maybe you can try using WordPress as a framework. It has the categories other other taxonomies built-in.

lordspace is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Bookmarks

Tags
needed, php, problem

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 02:55 PM.