从查询字符串(表tr td)foreach行获取值到jquery ui对话框

i have some code, see:

<script>
  $$.ready(function() {             
  // Profile Dialog
                
  $( "#user-dialog" ).dialog({
    autoOpen: false,
    modal: true,
    width: 400,
    open: function(){ $(this).parent().css('overflow', 'visible'); $$.utils.forms.resize() }
  }).find('button.submit').click(function(){
    var $el = $(this).parents('.ui-dialog-content');
    if ($el.validate().form()) {
      $el.dialog('close');
    }
  }).end().find('button.cancel').click(function(){
    var $el = $(this).parents('.ui-dialog-content');
    $el.find('form')[0].reset();
    $el.dialog('close');;
  });
                            
  $('#user-table').on('click', '.open-user-dialog', function(){
    $( "#user-dialog" ).dialog( "open" );
    return false;
  });
});
</script>
<table id="user-table">
<thead>
    <tr>
    <th>id</th>
    <th>name</th>
    <th>action</th>
    </tr>
</thead>
<tbody>
<?php

$sql = "SELECT id,user_name FROM users";

if ($result = $verbindung->query($sql)) {
while ($row = $result->fetch_assoc()) {
?>           
    <tr>
    
    <td><?php echo $row["id"];?></td>
    <td><?php echo $row["user_name"];?></td>
    <td>  
        <button class="open-user-dialog"><img src="img/icons/packs/fugue/16x16/bullet_go.png"/> view</button>                       
   </td>

    </tr>
    <?php }} ?>
    
  </tbody>    
</table>

<div style="display: none;" id="user-dialog" title="user view">
                
        <form action="">

            <div class="row">
                <label>
                    <strong>User details</strong>
                </label>
                <div>
              <input type="text" id="user_id" value="<?php echo $id; ?>">
              <input type="text" id="user_name" value="<?php echo $user_name; ?>">                             
                </div>
            </div>
        </form>
        
        <div class="actions">
            <div class="left">
                <button class="grey cancel">cancel</button>
            </div>
            <div class="right">
                <input id="submit" onclick="userFunction()" type="button" value="go">
            </div>
        </div>                
</div>

How i get my details from table to my jquery dialog?

the dialog is working fine, but i dont get the values $row['id'] and $row['user_name'] to display in my jquery dialog.

What I also try, I do not get the data in my dialog to be able to process them further.

How i can pass $row['id'] and $row['user_name'] for each line to my dialog?

Can someone Help me?

</div>

Firstly you add Php code in Php tags.You don't write if and while in php.

<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>action</th>
</tr>
</thead>
 <tbody>
 <?php  
 if ($result = $verbindung->query($sql)) {
while ($row = $result->fetch_assoc()) {
 ?>       
<tr>

<td><?php echo $row["id"];?></td>
<td><?php echo $row["user_name"];?></td>
<td>  
    <button class="open-user-dialog"><img src="img/icons/packs/fugue/16x16/bullet_go.png"/> view</button>                       
</td>

  </tr>
    <?php }}    ?>

  </tbody>  
  </table>

    <div style="display: none;" id="user-dialog" title="user view">

                <form action="">

                    <div class="row">
                        <label>
                            <strong>User details</strong>
                        </label>
                        <div>
              <input type="text" id="user_id" value="<?php echo $id; ?>">
<input type="text" id="user_name" value="<?php echo $user_name; ?>">                             
                        </div>
                    </div>
                </form>

                <div class="actions">
                    <div class="left">
                        <button class="grey cancel">cancel</button>
                    </div>
                    <div class="right">
                        <input id="submit" onclick="userFunction()" type="button" value="go">
                    </div>
                </div>              

try this