Search the Community
Showing results for tags 'inherritance'.
Long ago I started with a php function that generated an html select list from a mysql table. Over time, I've needed versions that did various things differently (two fields displayed between the <option> and </option> or a div displayed based on the selected value) so I've kept building new versions. Every time I build a new version I think "boy I should make a class and extend it to do things the new way" but I never have and now I must have half a dozen versions of the code. Today I sat down and started coding my class and quickly realized that I need to actually figure out what I put in the parent class and where I draw the line and create another class based on the first. Mostly I code procedural and I could really use some help thinking this through. Here's what I have in terms of permutations that I want to accomplish: Build an SQL select set a where clause set an order by select multiple columns to concatenate as labels (for example: <option citycode='$cid'>$city, $state, $country</option> ) Build html Allow list to start with value ='' (eg <option value=''>Choose a state</option> <option value='AK'>Alaska...) set a selected= value (or values for multiples) <div> s No <div> display Display of a <div> if other is selected input type=text textarea Display of a <div> for each value seected Types Select list single or multiple Radio checkboxes So, do I create a class with methods for each type of html list and a child class for the divs? A parent with the divs and children where I override the method that created the html for radio and checkboxes, something else entirely? Thanks, David