demanon Posted July 31, 2006 Share Posted July 31, 2006 hello all,i'm just beginning to learn php and needed some help with a project i've been assigned. basically, i need a way for non-technical people to be able to create/populate multiple html tables (2 columns, maybe 4-5 rows) and html is WAAAY over their heads. I thought to begin with I'd just create the table template with dummy text and let them update the code, but they all just looked at me with blank expressions. What I'm looking to do is setup a simple php form that will have a few text boxes and once they fill those in and click 'submit' it will display the entire pre-formatted html table code with their entries included in the appropriate place. that way, they'll just be able to copy the entire html table code and paste it where necessary. any help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/16074-populate-html-table-with-php/ Share on other sites More sharing options...
wildteen88 Posted July 31, 2006 Share Posted July 31, 2006 SOmething like this:[code]<?phpif(isset($_POST['genCode'])){ // echo '<pre>' . print_r($_POST['tool'], true) . '</pre><br /><br />'; echo '<h1>Generating HTML...</h1>'; $html = <<<HTML<table width="90%" border="1" cellpadding="7"> <tr bgcolor="#66ccff"> <td><big>"Problem/Error":</big> {$_POST['problem']}</td> </tr> <tr bgcolor="#ccffff"> <td><big>"Cause":</big> {$_POST['cause']}</td> </tr> <tr> <td><big>"Solution":</big> {$_POST['solution']}</td> </tr> <tr bgcolor="#dddeee"> <td><big>"Tools":</big> <table width="100%" border="1" cellpadding="7">HTML; $i = 0; foreach($_POST['tool']['name'] as $tools => $tool) { $html .= <<<HTML <tr bgcolor="#dddeee"> <td width="40%">"{$tool}"</td> <td>{$_POST['tool']['desc'][$i]}</td> </tr>HTML; $i++; } $html .= <<<HTML </table> </td> </tr></table>HTML; echo '<textarea cols="100" rows="20">' . $html . '</textarea>';}else{?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table cellpadding="7" cellspacing="0" border="1" width="90%"> <tr> <td><big>"Problem/Error":</big> <input name="problem" type="text" /></td> </tr> <tr> <td><big>"Cause":</big> <input name="cause" type="text" /></td> </tr> <tr> <td><big>"Solution":</big> <input name="solution" type="text" /></td> </tr> <tr> <td colspan="2"> <big>"Tools":</big> <table align="center" width="98%" cellpadding="7" cellspacing="0" border="1" style="margin: 1%;"> <tr> <td>"Tool Name"</td> <td>"Tool Description"</td> </tr> <?php for($i=0; $i < 5; $i++) { ?> <tr> <td width="40%"><input name="tool[name][]" type="text" size="50" /></td> <td><input name="tool[desc][]" type="text" size="80" /></td> </tr> <?php } ?> </table> </td> </tr> <tr><td colspan="2"><input type="submit" name="genCode" value="Generate HTML" /></td></tr> </table></form><?php}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16074-populate-html-table-with-php/#findComment-66282 Share on other sites More sharing options...
demanon Posted July 31, 2006 Author Share Posted July 31, 2006 awesome! thank you so much. now that i see how it's done it will be easier for me to understand how it works. Quote Link to comment https://forums.phpfreaks.com/topic/16074-populate-html-table-with-php/#findComment-66475 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.