razorsese Posted April 10, 2012 Share Posted April 10, 2012 Whit my code it only appear a list of 1 or 0 and the id but I don't know how to get to show only the id Like so: submit 0 60/ 0 59/ 0 58/ 0 57/ 0 56/ 0 45/ 0 38/ 1 37/ on my first page: <table border="2"> <tr> <th>Id</th> <th>User</th> <th>Comment</th> <th>Yes</th> <th>No</th> </tr> <form method="post" action="admincommentdelete.php" id="formc"> <?php $vv = array(); $st = Comment::test($result['article']->id,0,999); $vv['comment'] = $st['comment']; $i = 0; foreach($vv['comment'] as $p) { $i++; echo "<tr>"; echo "<td>".$p->id."</td>"; echo "<td>".$p->usern."</td>"; echo "<td>".$p->com."</td>"; echo "<td><input name=$i type=radio value='1'/></td>"; echo "<td><input name=$i type=radio value='0'/></td>"; echo "<input type=hidden name=h".$i." value=$p->id/>"; echo "</tr>"; } ?> <input type="submit" value="submit" name="submit"> </form> </table> second: <?php $id = array(); if(isset($_POST['submit'])) { $data = array(); $data = $_POST; foreach($data as $key) { echo $key."</br>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260692-php-getting-form-input/ Share on other sites More sharing options...
xyph Posted April 10, 2012 Share Posted April 10, 2012 Read foreach in the manual. Here's a hint. <?php $array = array( 'key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3', 'key4' => 'val4' ); echo '<pre>Dump for testing: '; print_r( $array ); echo '</pre>'; foreach( $array as $key => $value ) { echo "~$key - $value~<br>"; } ?> Hope that helps you find the solution. Quote Link to comment https://forums.phpfreaks.com/topic/260692-php-getting-form-input/#findComment-1336132 Share on other sites More sharing options...
razorsese Posted April 10, 2012 Author Share Posted April 10, 2012 Thank you very much:) Quote Link to comment https://forums.phpfreaks.com/topic/260692-php-getting-form-input/#findComment-1336148 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.