<p><?php include 'header.php'; ?></p>
<div align="justify">
<td>Name:<input type="text" name="password" ></td> <!-- database -->
<td> Rank:<select>
<!--<option value="volvo">//Database</option>
<option value="saab">Saab</option>
-->
<?php
require ("dbfunction.php");
$con = getDbConnect();
<td> <input type="checkbox" name="vehicle" value="Bike">Group by Rank</td> <!-- database -->
<td> <input type="checkbox" name="vehicle" value="Bike">Include previous service terms</td> <!-- database -->
</div>
<p><table>
<tr>
<th>Name</th>
<th>Rank</th>
<th>Start Date</th>
<th>End Date</th>
<th>Watchkeeping</th>
<th>Active</th>
<th></th>
<th></th>
</tr> <!-- database -->
<tr> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php
if (!mysqli_connect_errno($con)) {
$queryStr = "SELECT * " .
"FROM crewlist";
}
$result = mysqli_query($con, $queryStr);
while ($row = mysqli_fetch_array($result)) {
//echo "<div><a href=http://localhost/poshproject/crewlisting.php?crew_name={$row["crew_id"]}>";
echo "<tr>.<th>" . $row["crew_name"] . "<br></br>" . "</th>";
echo "<th>" . $row["crew_rank"] . "</th>";
echo "<th>" . $row["start_date"] . "</th>";
echo "<th>" . $row["end_date"] . "</th>";
echo "<th>" . $row["watchkeeping"] . "</th>";
echo "<th>" . $row["active"] . "</th>";
echo "<td><a href=\"editcrew.php?id=" . $row['crew_id'] . "\">Edit</a>";
//echo "<td><center><button type=\"submit\" name=\"Delete\" value="' . $row['crew_id'].'"/>Delete</button></center></td>";
echo "<td><a href=\"delete.php?id=" . $row['crew_id'] . "\">Delete</a>";
}
?>
<!--
<td><center><button type="submit" value="Edit">Edit</button></center></td>
<td><center><button type="submit" value="Delete">Delete</button></center></td>-->
</form></tr>
</tr>
</table>
---------------------delete.php---------------------
<?php
//print_r($_GET);
include 'dbfunction.php';
$con = getDbConnect();
if (!mysqli_connect_errno($con)) {
$queryStr = "SELECT * FROM crewlist";
}
$result = mysqli_query($con, $queryStr);
while ($row = mysqli_fetch_array($result)) {
if (!mysqli_connect_errno($con)) {
$sqliQueryStr = "DELETE FROM `posh`.`crewlist` WHERE crew_id = ". $row['crew_id'] . "";
}
mysqli_query($con, $sqliQueryStr);
header('Location: crewlisting.php');
mysqli_close($con);
//echo "user has been deleted";
}
?>
删除功能仅适用于数据库的第一行。当我删除不是第一行的行时,它会删除第一行。
,当我尝试了很多东西时,不确定错误在哪里。答案 0 :(得分:0)
更改您的删除查询,如下所示
library(grid)
# devtools::install_github('baptiste/gridextra')
library(gridExtra)
df <- data.frame(id = c("a","b","c","d"),
s1.pch = c(NA,5,5,5),
s1.col = c(NA,"red","green","yellow"),
s2.pch = c(3,3,3,3),
s2.col = c("blue","red","green","yellow"),
s3.pch = c(1,1,NA,1),
s3.col = c("blue","red",NA,"yellow"))
d <- data.frame(id=df$id,
s1 = paste(df$s1.col, df$s1.pch, sep=","),
s2 = paste(df$s2.col, df$s2.pch, sep=","),
s3 = paste(df$s3.col, df$s3.pch, sep=","))
my_fun <- function(label, ...){
s <- strsplit(label, ",")[[1]]
col <- s[1]
pch <- ifelse(s[2]=="NA", NA, as.numeric(s[2]))
pointsGrob(0.5,0.5,pch=pch, gp=gpar(col=col, lwd=3, cex=0.5))
}
tt <- ttheme_minimal(12, core=list(fg_fun = my_fun),
rowhead=list(fg_params=list(fontface="bold")))
grid.newpage()
grid.table(d[,-1], rows=levels(d[,1]), theme = tt)