mysql - Create and get dynamic variable with php -


i know question been asked , answered, , not sure proper question should ask, pardon me :d

what im trying is:

  • i got table, value mysql , paste table through loop
  • for each row give button (edit button)
  • i give each button id of value through variable $id (eg. 1 2 3 4 )

my question how can specify button press $_post? tried every way think of not work ( in code below warp id variable=asdf static can last value of 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 $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 way use jquery , ajax sadly cant work, way php alone?

i'll offer replace row:

<td><input type="submit" class="edit" name="<?php $a=$row['id']; $$a='asdf'; echo $$a; ?>" value="edit" /></td> 

by:

<td><button class="edit" name="act" value="<?php echo  $row['id'];?>">edit</button></td> 

after you'll check value of $_post['act']


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -