我有一张表正在回复,现在我在它的末尾添加了一个复选框。
我想检查那个方框。可以检查多个项目,然后单击保存按钮。它将转到帖子页面并在数据库中设置完成,以便"是"对于所有已检查的ID。
问题是我不明白复选框在知道哪个ID
进入帖子页面后会如何知道。
<?php
$conduct = $_SESSION['username'];
$query = mysqli_query($con, "SELECT * FROM newworders WHERE train = 'Yes' AND conductor = '$conduct' AND complete = ' '");
echo "<table id='tb' border='1'>
<tr class='head'>
<th>First Name</th>
<th>Last Name</th>
</tr>";
while($row = mysqli_fetch_array($query)) {
echo "<tr>";
echo "<td>" . '<a href="orderpage.php?uid=' . $row['ID'] . '">' . $row['first'] . '</a><br />' . "</td>";
echo "<td>" . '<a href="orderpage.php?uid=' . $row['ID'] . '">' . $row['last'] . '</a><br />' . "</td>";
echo "<td>"."<input type='checkbox' value='Yes' name='complete'" . "</br>". "</td>";
}
<div class='new'>
<form action="savepending.php" method='POST'>
<input type='submit' name ='save'/>
</form>
</div>
然后是帖子页。
<?php
if(isset($_POST['save']))
{
$query = mysqli_query($con, "UPDATE newworders SET complete = 'Yes' WHERE ")
}
?>
我不知道在WHERE
部分放什么。我只是不明白它将如何判断哪个ID
是哪个。
答案 0 :(得分:0)
使您的复选框成为arrray,由complete
主键索引。然后你可以迭代 package magicsquare;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
public class MagicSquare {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\n\nEnter the size of the matrix : ");
int n = Integer.parseInt(br.readLine());
if (n > 5 && n < 2) {
System.out.println("Enter a number between 2 to 5 ");
} else {
int A[][] = new int[n][n]; // Creating the Magic Matrix
int i, j, k, t;
/*Initializing every cell of the matrix with 0 */
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
A[i][j] = 0;
}
}
/* When the size of the matrix is Odd */
if (n % 2 != 0) {
i = 0;
j = n / 2;
k = 1;
while (k <= n * n) {
A[i][j] = k++;
i--; // Making one step upward
j++; // Moving one step to the right
if (i < 0 && j > n - 1) // Condition for the top-right corner element
{
i = i + 2;
j--;
}
if (i < 0) // Wrapping around the row if it goes out of boundary
{
i = n - 1;
}
if (j > n - 1) // Wrapping around the column if it goes out of boundary
{
j = 0;
}
if (A[i][j] > 0) // Condition when the cell is already filled
{
i = i + 2;
j--;
}
}
} /* When the size of the matrix is even */ else {
k = 1;
/* Filling the matrix with natural numbers from 1 till n*n */
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
A[i][j] = k++;
}
}
j = n - 1;
for (i = 0; i < n / 2; i++) {
/* swapping corner elements of primary diagonal */
t = A[i][i];
A[i][i] = A[j][j];
A[j][j] = t;
/* swapping corner elements of secondary diagonal */
t = A[i][j];
A[i][j] = A[j][i];
A[j][i] = t;
j--;
}
}
/* Printing the Magic matrix */
System.out.println("The Magic Matrix of size " + n + "x" + n + " is:");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
//remove random element from array
Random rand = new Random();
for (i = 0; i < 4 ; i++)
{
int randomNum1 = rand.nextInt((n-1) - 0 + 1) + 0;
int randomNum2 = rand.nextInt((n-1) - 0 + 1) + 0;
BufferedReader dr = new BufferedReader(new InputStreamReader(System.in));
A[randomNum1][randomNum2] = Integer.parseInt(dr.readLine());
}
System.out.print(A[i][j] + "\t");
}
System.out.println();
}
}
}
}
。 PHP数组是关联的,因此您只有复选框所需的元素。