Javascript 如何让链接在传输到下一页之前记住它作为href的值

Javascript 如何让链接在传输到下一页之前记住它作为href的值,javascript,php,jquery,html,Javascript,Php,Jquery,Html,通过研究,我找到了一种将数据库中的信息显示在php页面中的简洁方法 现在,我的下一个目标是将每一行链接到另一个php页面,该页面将识别用户单击的帐户ID echo "<table border='1'> <tr> <th>Account ID</th> <th>Account Username</th> <th>Account Password</th> <th>Account Firs

通过研究,我找到了一种将数据库中的信息显示在php页面中的简洁方法

现在,我的下一个目标是将每一行链接到另一个php页面,该页面将识别用户单击的帐户ID

echo "<table border='1'>
<tr>
<th>Account ID</th>
<th>Account Username</th>
<th>Account Password</th>

<th>Account First Name</th>
<th>Account Middle Name</th>
<th>Account Last Name</th>

<th>Account Phase</th>
<th>Account Block - Lot</th>
<th>Account Subdivision</th>

<th>Account Contact Number</th>
<th>Account Email Address</th>
<th>Account Status</th>

</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['acc_no'] . "</td>";
echo "<td>" . $row['acc_user'] . "</td>";
echo "<td>" . $row['acc_pass'] . "</td>";

echo "<td>" . $row['acc_fname'] . "</td>";
echo "<td>" . $row['acc_mname'] . "</td>";
echo "<td>" . $row['acc_lname'] . "</td>";

echo "<td>" . $row['acc_phase'] . "</td>";
echo "<td>" . $row['acc_blk-lot'] . "</td>";
echo "<td>" . $row['acc_subd'] . "</td>";

echo "<td>" . $row['acc_contact_num'] . "</td>";
echo "<td>" . $row['acc_email_address'] . "</td>";
echo "<td>" . $row['acc_status'] . "</td>";

echo "</tr>";
}
echo "</table>";
我试过这个回声$第[‘附件编号’]行。但是生成的所有链接都具有相同的值。我认为JQuery可能是这个或其他东西所需要的,但不幸的是,我们学校还没有教过这个东西,或者可能有更好的方法解决我的问题。请帮忙

我的意思是,我不知道如何在While循环中集成逻辑 只要循环未完成,这是否意味着$\u GET或 $\u POST将循环使用它吗

首先创建自定义URL,这可以在没有表单的情况下完成,只需创建一个指向该位置的链接,并在其末尾添加一个查询字符串

在第一次页面加载时,isset$\u GET['id']将永远不会为真,因为用户可能还没有选择帐户。第一个页面加载为特定用户创建表以及所有链接。URL是唯一的,因为它们是使用帐号创建的。对于帐户1,URL指向thisScript.php?id=1;对于帐户987,URL指向thissiprt.php?id=987

当用户选择帐号时,会出现一个新表单,允许他们更改字段。这是因为$_GET['id']将被设置为所选的帐号。我们可以将该输入与数据库中的字段进行比较,从而允许所有其他行都不具有该表单

这只是一个可行的例子。所包含的表格将中断可能看起来有点粗俗的对话

这是否意味着$\u GET或$\u POST将与其循环


$\u GET和$\u POST是在while之外定义的,这意味着它们不会被重复定义。但是,它们在while循环的作用域内,如我所展示的示例所示。

目前只是一个占位符,我不懂PHP,但它应该类似于:echo$第[‘附件编号’]行@dimakura,您的建议意味着每个帐户都应该有特定的页面。我在寻找一种方式,当管理员转移到目标php页面时,他可以将所选的$row['acc_no']信息保存下来manipulated@MattYo如果你有像/accounts/1、/accounts/2这样的链接,在专用页面上提取id=1和id=2部分有什么问题?每个特定帐户可能都有一个页面-只需让页面接受输入即可操作帐户。如果您不喜欢这样,请将链接点添加到自身,并添加一个查询字符串:?id=$row['acc_no'],然后将字段放在那里。只有当您想使用ajax时,jQuery才会在这里发挥作用——这对您现在来说似乎太复杂了。
while($row = mysql_fetch_array($result))
{
echo "<tr>";
// Step 1.
// Create a custom URL that points to this same script, 
// passing the account number as a $_GET parameter.
echo '<td><a href="thisScript.php?id=' . $row['acc_no'] . '">' . $row['acc_no'] . "</a></td>";
echo "<td>" . $row['acc_user'] . "</td>";
echo "<td>" . $row['acc_pass'] . "</td>";

echo "<td>" . $row['acc_fname'] . "</td>";
echo "<td>" . $row['acc_mname'] . "</td>";
echo "<td>" . $row['acc_lname'] . "</td>";

echo "<td>" . $row['acc_phase'] . "</td>";
echo "<td>" . $row['acc_blk-lot'] . "</td>";
echo "<td>" . $row['acc_subd'] . "</td>";

echo "<td>" . $row['acc_contact_num'] . "</td>";
echo "<td>" . $row['acc_email_address'] . "</td>";
echo "<td>" . $row['acc_status'] . "</td>";

echo "</tr>";

// Step 2.
// Check if the user has already clicked a one of the URLs we custom made in step 1.
if (isset($_GET['id'] && $_GET['id'] == $row['acc_no']){
     // the user has, so let's allow them to change the fields.
     // This form appears directly under the record that was clicked.
     echo '<form action="commitChangesScript.php" method="post">';
     echo '<input type="text" name="fname">';
     //repeat for any fields you want to be able the change.
     // ...
     echo '</form>';
}
}