您好我有一个查询列出al用户,我希望能够点击用户名,然后转到用户信息页面,所以我的问题是如何将用户名传递给其他php。
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td><font color='white'>" . ++$i . "</font></td>";
echo "<td><a href='page2.php'><font color='white'>" . $row['1'] . "</font></a></td>";
echo "<td><font color='white'>" . $row['2'] . "</font></td>";
echo "<td><font color='white'>" . $row['3'] . "</font></td>";
echo "<td><font color='white'>" . $row['4'] . "</font></td>";
echo "</tr>";
}
表格很好我只需要一种方法将select用户名传递给page2.php。
提前致谢
编辑:
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td><font color='white'>" . ++$i . "</font></td>";
echo "<td><a href='page2.php?nome='".$row['nome']."><font color='white'>" . $row['nome'] . "</font></a></td>";
echo "<td><font color='white'>" . $row['sexo'] . "</font></td>";
echo "<td><font color='white'>" . $row['idade'] . "</font></td>";
echo "<td><font color='white'>" . $row['diabetes'] . "</font></td>";
echo "</tr>";
}
使page2.php:
include_once 'ligacao.php';
$name = $_GET['nome'];
echo "<table border='1' align='center'>
<tr>
<th><font color='white'>Registo</font></th>
<th><font color='white'>Name</font></th>
</tr>";
echo "<tr>";
echo "<td><font color='white'>" . ++$i . "</font></td>";
echo "<td><font color='white'>" . $name . "</font></td>";
echo "</tr>";
编辑2:
如何在页面中间并排排列2张桌子?
echo "<table border='1'>
<tr>
<th><font color='white'>Glicemia</font></th>
<th><font color='white'>Hidratos</font></th>
<th><font color='white'>Peso</font></th>
<th><font color='white'>Descrição</font></th>
<th><font color='white'>Timestamp</font></th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td><font color='white'>" . $row['glicemia'] . "</font></td>";
echo "<td><font color='white'>" . $row['hidratos'] . "</font></td>";
echo "<td><font color='white'>" . $row['peso'] . "</font></td>";
echo "<td><font color='white'>" . $row['descricao'] . "</font></td>";
echo "<td><font color='white'>" . $row['time'] . "</font></td>";
echo "</tr>";
}
echo "<table border='1'>
<tr>
<th><font color='white'>Medicamento</font></th>
<th><font color='white'>Timestamp</font></th>
</tr>";
while($row = mysql_fetch_array($resultq)) {
echo "<tr>";
echo "<td><font color='white'>" . $row['medicamento'] . "</font></td>";
echo "<td><font color='white'>" . $row['time'] . "</font></td>";
echo "</tr>";
}
答案 0 :(得分:0)
您可以将其作为url参数传递,并在$_GET
中使用page2.php
,例如:
...
"<td><a href='page2.php?username='".$row[1].">...</a>
...
并在page2.php
$username = $_GET['username'];
<强>更新:: 强> 您的代码似乎有引号问题,请尝试更改为:
....
echo "<td><a href='page2.php?nome=" . $row['nome'] . "'><font color='white'>" . $row['nome'] . "</font></a></td>";
...