Pope94IA Posted February 20, 2013 Share Posted February 20, 2013 (edited) I am creating a scoring system for deer and I have a form that asks for the measurements. I also have an option that adds more forms (if the deer has more than 4 tines, or 4 abnormal points). Now when I submit my form it sends it a /add.php. I have it so it displays the original forms and then I want to make it so it shows the addition forms. BUT only if they used that form. So basically I want it to display the measurement in the fields ONLY if they were used. <?php $a = $_GET['a']; $b = $_GET['b']; $c = $_GET['c']; $d = $_GET['d']; //....continueing on....// $answer = $a + $b + $c + $d + $e + $f + //....continue...// ?> I have the above code in my /add.php to pull in the information from my forms. <table width="400" id="file_d" style="display:none" cellspacing="0" cellpadding="0" border="0"> <tr> <td width="35"><b>Ab6</b></td> <td width="100"><input type="text" name="pp"></td> <td width="50"> </td> <td width="100"><input type="text" name="qq"></td> </tr> <tr> <td colspan="4"> <a href="#" id="link_d" onclick="new_field('file_e');hide_mais('link_d')">Add More</a> </td></tr><br></table> The above code is to add more fields (along with a ID set in the table). Basically when you click add more it adds the next field. So for the above example it displays "D" and then when clicked add more it displays "E" which is just another table. This above code is in my forms on a seperate page <input type="text" name="pp"> The above is an example of one of the forms that im using. I am wanting to display the original fields (a,b,c,d,etc..) and then if someone had clicked "add more" and entered in another field. I want that field to be displayed as well (aa,bb,cc,etc...) I tried something like <?php if (!isset($_POST['q']) || empty($_POST['q'])) { echo "<tr> <td width='40'>G5:</td> <td width='50'><?php echo $q; ?></td> </tr>"; } ?> But that just displays the field regardless of whether or not information was put in. Any help would be appreciated! Edited February 20, 2013 by Pope94IA Quote Link to comment https://forums.phpfreaks.com/topic/274744-php-form-display-fields-with-input/ Share on other sites More sharing options...
mweldan Posted February 20, 2013 Share Posted February 20, 2013 send it as array change name="pp" to name="pp[]" on file that processing it use print_r($_POST) to see how it look like. so you will know how to manipulate it for later. Quote Link to comment https://forums.phpfreaks.com/topic/274744-php-form-display-fields-with-input/#findComment-1413722 Share on other sites More sharing options...
exeTrix Posted February 21, 2013 Share Posted February 21, 2013 This is purely from memory but if you wanted to add more fields you could do this with some sort of client side script to make it a bit more seamless: <input type="text" name="input[]" /> <input type="text" name="input[]" /> Then in PHP: //below should return an array with both values of the input print_r( $_POST['input'] ); Quote Link to comment https://forums.phpfreaks.com/topic/274744-php-form-display-fields-with-input/#findComment-1413839 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.