i know this question probably been asked and answered, and i also not sure what proper question i should ask, so pardon me :D
what im trying to do is:
- i got a table, i get the value from mysql and paste it into the table through a LOOP
- for each row i give it a button (edit button)
- i give each button the id of value through a variable $id (eg. 1 2 3 4 )
my question is how can i get the specify button that i press by $_POST? i tried every way i could think of but it not work ( in my code below i warp the id with another variable=asdf so that it static but i can only get the last value of the id)
$viewvalue = mysqli_fetch_all ($result, MYSQLI_ASSOC);
<?php if (count($viewvalue) > 0): ?>
<table id="t01">
<thead>
<tr>
<th><?php echo implode('</th><th>', array_keys(current($viewvalue))); ?></th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php foreach ($viewvalue as $row): array_map('htmlentities', $row); ?>
<tr>
<td><?php echo implode('</td><td>', $row);?></td>
<td><input type="submit" class="edit" name="<?php $a=$row['id']; $$a='asdf'; echo $$a; ?>" value="Edit" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php
if(isset($_POST['asdf'])){
echo $a;
}
?>
i know theres a way to use jquery and ajax but sadly i cant get it to work, is it a way to do it with php alone?