venky_lb Posted July 3, 2008 Share Posted July 3, 2008 Hi, consider the following example id code description parent 1 01 car 0 2 011 hyundai 01 3 0111 verna 011 4 02 bus 0 ig goes like this, now if i delete car that should not be deleted because it has subcategories,but i should be able to delete categories which doesnt has subcategory i.e bus . pls help me out in this. Regards venkat Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/ Share on other sites More sharing options...
Pickle Posted July 3, 2008 Share Posted July 3, 2008 Can i ask what you are asking for here? are you needing help with the SQL Query? Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/#findComment-581191 Share on other sites More sharing options...
teynon Posted July 3, 2008 Share Posted July 3, 2008 To clarify for him: he seems to be asking about the logic of it. Personally I wouldn't do the categories like that in the database.... But if you don't want it to be deleted, you will have to do a check before you delete it. For example: SELECT * FROM table WHERE CODE LIKE '01%' if (mysql_num_rows($query) > 1), then it should not be deleted. Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/#findComment-581196 Share on other sites More sharing options...
discomatt Posted July 3, 2008 Share Posted July 3, 2008 Here's a great article on hierarchies in databases http://dev.mysql.com/tech-resources/articles/hierarchical-data.html Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/#findComment-581197 Share on other sites More sharing options...
venky_lb Posted July 4, 2008 Author Share Posted July 4, 2008 Thanks for ur help. Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/#findComment-581666 Share on other sites More sharing options...
venky_lb Posted July 9, 2008 Author Share Posted July 9, 2008 Hi, consider the following example id code category parent 1 01 car 0 2 011 hyundai 01 3 0111 verna 011 4 02 bus 0 5 021 volvo 02 it goes like this, can any one tell the logic how to add a new subcategory, which should automatically increment the code i.e my html form for adding record ->used select button and displayed all category in it, ->used a text boc to enter the new record now,i can select anyone of category from select menu(eg car) and entered a new record (eg ferrari).if i click submit it should be stored in db such a way that code 012 pls help me out in this. Link to comment https://forums.phpfreaks.com/topic/113052-help-me-in-deleting-category-and-its-subcategory-in-a-tree/#findComment-585095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.