Jump to content

PHP getting form input


razorsese

Recommended Posts

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>";
}
}



?>

Link to comment
https://forums.phpfreaks.com/topic/260692-php-getting-form-input/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.