ryanfait Posted March 13, 2010 Share Posted March 13, 2010 I coded a script in PHP, but I did it poorly and I'm looking to start from scratch. Here's the HTML concept: http://signwavedigital.com/-ryan/ I can't come up with a simple way to associate the text submitted in the text boxes with their parent checkbox in a single database row. It goes the other way too: I need to be able to take the data from a database entry and turn it back into that HTML format. The only thing I can think of is to use some type of multi-level array, but I'm not sure how to go about that. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/195083-structuring-data/ Share on other sites More sharing options...
teamatomic Posted March 13, 2010 Share Posted March 13, 2010 We'll take your first set as an example: <div id="ballys"> <input type="checkbox" name="properties[]" value="ballys" /> Bally's<br /> <div id="screensballys"> <label>Bally's screens this spot will appear on</label><br /> <input type="text" name="ballysscreens[]" value="" class="text" /><br /> </div> Make all your text widgets use the same array. Then make it an associative array by using the checkbox value as the key. That way looping through the properties array you can use the value as a key in the text_widget array to get at the matching text_widget value. <div id="ballys"> <input type="checkbox" name="properties[]" value="ballys" /> Bally's<br /> <div id="screensballys"> <label>Bally's screens this spot will appear on</label><br /> <input type="text" name="text_widget[ballys]" value="" class="text" /><br /> </div> foreach($properties as $key) { echo "$key text is {$text_widget[$key]}"; } HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/195083-structuring-data/#findComment-1025522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.