【问题标题】:how to get the value of a user_id link from html table using php如何使用 php 从 html 表中获取 user_id 链接的值
【发布时间】:2011-04-06 08:14:46
【问题描述】:

$row[0] 是 user_id 当我点击 user_id 我需要知道如何使用 php 从 html 表中获取我点击的值,所以我可以使用这个 id 将其数据选择到另一个表单中,以便我可以编辑它

p>
$select = "SELECT U.id, U.first_name, U.last_name, U.email_address, U.password, U.gender, U.day, U.month, U.year, COUNT(O.user_id) FROM users U LEFT JOIN orders O ON U.id = O.user_id GROUP  BY U.id ORDER BY id $order LIMIT $offset , $rowsPerPage";    
$result=mysql_query($select) or die(mysql_error());
while($row=mysql_fetch_array($result)){ ?>

<table>
<tr>      
    <td><?php echo "<a href= 'editUser.html'> $row[0]</a>"; ?></td>
    <td><?php echo $row[1];?></td>
    <td><?php echo $row[2];?></td>
    <td><?php echo $row[3];?></td>
    <td><?php echo $row[4];?></td>
    <td><?php echo $row[5];?></td>
    <td><?php echo $row[6];?></td>
    <td><?php echo $row[7];?></td>
    <td><?php echo $row[8];?></td>
    <td><?php echo $row[9];}
    </tr>
</table>

【问题讨论】:

    标签: php html


    【解决方案1】:

    作为查询字符串传递并将在$_GET中可用

    <td><?php echo "<a href= 'editUser.html?id=".$row[0]."'> $row[0]</a>"; ?></td>
    

    你可以这样进入下一页

    echo $_GET['id'];
    

    【讨论】:

      【解决方案2】:

      您无法从 HTML 表格中“获取”ID。
      您只能使用超链接发送它

      $select = "SELECT U.id, U.first_name, U.last_name, U.email_address, U.password, U.gender, U.day, U.month, U.year, COUNT(O.user_id) FROM users U LEFT JOIN orders O ON U.id = O.user_id GROUP  BY U.id ORDER BY id $order LIMIT $offset , $rowsPerPage";    
      $result=mysql_query($select) or die(mysql_error());
      while($row=mysql_fetch_array($result)){ 
        $data[] = $row;
      }
      ?>
      
      <table>
        <tr>
      <? foreach($data as $row) { ?>
          <td><a href="edituser.php?id=<?php echo $row['id']?>"><?php echo $row['id']?></a></td>
      <? } ?>
        </tr>
      </table>
      

      【讨论】:

        【解决方案3】:

        您可以使用 Ajax 请求将数据从表发送到服务器。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-07-19
          • 2016-02-03
          • 1970-01-01
          • 1970-01-01
          • 2013-05-11
          • 2011-03-05
          • 2018-08-04
          相关资源
          最近更新 更多