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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.