douliu8327
2016-01-05 11:43
浏览 35
已采纳

PDO PhP - 从选择ID中删除查询

I'm trying to make it so when i click a "x" it will delete the entire row. I've linked each record to my jobRef however the delete isn't working.

This is what i've got so far;

<?php
$status = 'available';
$stmt = $pdo->query('SELECT * FROM jobs WHERE jobStatus = "' . $status . '"');
$results = $stmt->fetchAll();

echo "<table><tr><td>Job Reference</td><td>Description</td>";
foreach ($results as $row) {
  echo "<tr><td>".$row['jobRef']."</td>","<td>".$row['jobDescription']."</td>";
  echo "<td><a href='edit.php?id=".$row['jobRef']."'>Edit</a></td>";
?>

Heres my delete.php

<?php
require 'mysqlcon.php';

?>

<?php

if(isset($_GET['id']))
{
$id=$_GET['id'];
$query1= ("DELETE FROM person WHERE id='$id'");
if($query1)
{
header('location:Vacancies.php');
}
}
?>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题