通过URL 2 Var发送(1个已选中,1个已登录用户)

时间:2015-04-14 10:09:07

标签: php mysql

我正在尝试向一个页面发送超过2个变量 - 1是登录用户,另一个是已登录用户更新了配置文件的注册用户的ID。

我不知道如何更改我的页面。

<?php
    include("includes/connect.php");

    //logged in users ID from logged in page.
    $id = $_GET['id'];

    $sql="SELECT * FROM guild_apply";
    $result=mysql_query($sql);

?>

<blockquote>
<table border='1' width='100%'>
<tr>
    <th>ID </th>
    <th>Real Name</th>
    <th>Character Name</th>
    <th>Class</th>
    <th>Rank</th>
</tr>

<?php
     while($row = mysql_fetch_array($result)){
?>

 //info from all users registered with default rank (which is going to be changed)
<tr>
    <td><?php echo $row['id'];  ?> </td>
    <td><?php echo $row['realname'];    ?> </td>
    <td><?php echo $row['charname'];    ?> </td>
    <td><?php echo $row['class'];       ?> </td>
    <td><?php echo $row['rank'];            ?> </td>
    <td align="center"><a href="update.php?charname=<?php echo $row['charname']; ?>">update</a></td>
</tr>

<?php
     }
?>
</table>
</blockquote>

?>

------ ----- update.php

<?php

// Connect to server and select database.
include("connect.php");

$id         =$_GET['id'];
$rank       =$_POST['rank'];
$charname   =$_GET ['charname'];

// update data in mysql database 
$sql="UPDATE guild_apply SET rank='$rank' WHERE charname='$charname'" or die ("cant find learner");
$result=mysql_query($sql) or die ("this stuffedup");

if ($result){
    // if successfully updated. 
    header ("Location:../change.php?id=$id");
}else{
    echo "Update failed";
}
?>

1 个答案:

答案 0 :(得分:0)

在网址中添加&id=参数。

<td align="center"><a href="update.php?charname=<?php echo $row['charname']; ?>&id=<?php echo $id; ?>">update</a></td>