frozenlight777 Posted May 28, 2008 Share Posted May 28, 2008 I'm looping through an array with an xml file and it displays great...... <form method="POST" action="uploadlist.php"> <table align="center" border="1" width="600"> <tr> <th>Asset Tag</th> <th>Type</th> <th>Service Tag</th> <th>User</th> </tr> <?php foreach( $data as $row ) { ?> <tr> <td><input name="Asset_Tag" value = "<?php echo( $row['Asset_Tag']); ?> "/></td> <td><input name="Type" value = "<?php echo( $row['Type']); ?> "/></td> <td><input type="hidden" name="Service_Tag" value = "<?php echo( $row['Service_Tag']); ?>"/></td> <td><input name="User" value = "<?php echo($row['User']); ?> "/></td> <td><input type="hidden" name="_submit_check" value="1"/> </td> </tr> <?php } ?> <td><input type="submit" value="Send to Database"/></td> </table> </form> however, how can I display the same results in the uploadlist.php file... I can't seem to get the array to display with the POST variables..... and I have no idea what other way there is..... ideas? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 add [] to all of your input names...and if service tag is the unique id for each item, use this: <?php foreach( $data as $row ) { ?> <tr> <td><input type="text" name="Asset_Tag[<?php echo $row['Service_Tag']; ?>]" value="<?php echo $row['Asset_Tag']; ?>"/></td> <td><input type="text" name="Type[<?php echo $row['Service_Tag']; ?>]" value="<?php echo $row['Type']; ?>"/></td> <td><input type="text" name="User[<?php echo $row['Service_Tag']; ?>]" value="<?php echo $row['User']; ?>"/></td> <td><input type="hidden" name="_submit_check" value="1"/> </td> </tr> <?php } ?> Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 interesting.... now how would i display that on the other page...something like $_POST("Asset_Tag"); ? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 $_POST would now look something like this: Array ( 'Asset_Tag' => Array ( 'svc_tag_1' => 'Asset Tag for Service Tag 1', 'svc_tag_2' => 'Asset Tag for Service Tag 2', 'svc_tag_3' => 'Asset Tag for Service Tag 3', 'svc_tag_4' => 'Asset Tag for Service Tag 4' ), 'Type' => Array ( 'svc_tag_1' => 'Type for Service Tag 1', 'svc_tag_2' => 'Type for Service Tag 2', 'svc_tag_3' => 'Type for Service Tag 3', 'svc_tag_4' => 'Type for Service Tag 4' ), 'User' => Array ( 'svc_tag_1' => 'User for Service Tag 1', 'svc_tag_2' => 'User for Service Tag 2', 'svc_tag_3' => 'User for Service Tag 3', 'svc_tag_4' => 'User for Service Tag 4' ) ) to loop over the info: <?php foreach($_POST['Asset_Tag'] as $Service_Tag => $Asset_Tag){ $Type = $_POST['Type'][$Service_Tag]; $User = $_POST['User'][$Service_Tag]; print $Asset_Tag.' : '.$Type.' : '.$User; } ?> Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 i'm sorry to be a pain but each array is independent from eachother. What you posted seemed to work but it only displayed in the URL. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 put a print_r($_POST); on the page it submits to, and post what that outputs please Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 all it displays is: Array() with all the content in the URL Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 then something is wrong on your HTML page. can you do a view source on the page that display all the input boxes, and copy paste that? please use code tags if you do..it's the button with the # on it in the toolbar Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 upload.php <?php error_reporting(E_ALL); require_once( "include.php" ); XMLParse(); ?> <html> <form method="REQUEST" action="uploadlist.php"> <table align="center" border="1" width="600"> <tr> <th>Asset Tag</th> <th>Type</th> <th>Service Tag</th> <th>User</th> </tr> <?php foreach( $data as $row ) { ?> <tr> <td><input type="text" name="Asset_Tag[<?php echo $row['Asset_Tag']; ?>]" value="<?php echo $row['Asset_Tag']; ?>"/></td> <td><input type="text" name="Type[<?php echo $row['Type']; ?>]" value="<?php echo $row['Type']; ?>"/></td> <td><input type="text" name="Service_Tag[<?php echo $row['Service_Tag']; ?>]" value="<?php echo $row['Service_Tag']; ?>"/></td> <td><input type="text" name="User[<?php echo $row['User']; ?>]" value="<?php echo $row['User']; ?>"/></td> </tr> <?php } ?> <td><input type="submit" value="Send to Database"/></td> </table> </form> </html> and then the uploadlist.php file... which isn't anything yet except for <?php print_r($_POST); ?> Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 wow I apologize.... i used request instead of post.... been a long day... it displayed the whole array now... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 i was gonna say...originally you had it POST... Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 Great... thanks for you help i got the array working so now how would i go about looping the data like i did in the first table.. something like <?php foreach(????????] as ????){ echo "<td>$_POST['Asset_Tag']</td>"; echo "<td>$_POST['Type']</td>"; echo "<td>$_POST['Service_Tag']</td>"; echo "<td>$_POST['User']</td>"; } ?> not sure what the looping variables would be... Quote Link to comment Share on other sites More sharing options...
frozenlight777 Posted May 28, 2008 Author Share Posted May 28, 2008 nevermind i got it. foreach($_POST['Asset_Tag'] as $key => $value){ $Asset_Tag = $_POST['Asset_Tag'][$value]; print $Asset_Tag; echo "<br/>"; } thanks for you're help tho. you certainly got this working for me. Quote Link to comment 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.