как удалить одну строку вместо всех строк

Как мне удалить одну строку с кодом, который у меня есть. Это позволяет мне удалить все строки вместо одной строки с идентификатором, не уверенным, что я делаю неправильно, не уверенным, что у меня есть цикл или что.

<?php
include_once('dbconnect.php');
echo "<form action='delete.php' method='post' id = 'deleteForm'>";

$sqlARTICLEQuery = "SELECT * FROM articles where pageId=$paqueryRow[pageId] order by articleId";
$articlequeryResult = mysqli_query($conn,$sqlARTICLEQuery);
while ($articlequeryRow = mysqli_fetch_assoc($articlequeryResult))
{ echo "<input type = 'radio' name = '$articlequeryRow[articleId]' method = 'post'>".$articlequeryRow['articleId']."&nbsp".$articlequeryRow['articleTitle']."&nbsp";
echo "<input name='ARTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['ARTSubmit'])){
$artDeleteQuery = "DELETE FROM articles where pageId = $paqueryRow[pageId] AND articleId=$articlequeryRow[articleId].";

if(mysqli_query($conn, $artDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}
$sqlTEXTQuery = "SELECT * FROM text where articleId=$articlequeryRow[articleId] order by textId";
$textqueryResult = mysqli_query($conn,$sqlTEXTQuery);
while ($textqueryRow = mysqli_fetch_assoc($textqueryResult))
{
echo "<input type = 'radio' name = '$textqueryRow[textId]' method = 'post'>".$textqueryRow['textId']."&nbsp".$textqueryRow['textTitle']."&nbsp"; //how can I print articles.pageId to match with pages.pageId
echo "<input name='TEXTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['TEXTSubmit'])){
$textDeleteQuery = "DELETE FROM text where articleId = $articlequeryRow[articleId] AND textId = $textqueryRow[textId].";

if(mysqli_query($conn, $textDeleteQuery)){

echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}echo "<br />"}echo "<br />"}echo "</form>"$conn->close();
?>

0

Решение

Вы забыли заключительную цитату в строке 2 из эха. и я удалил точку позади вашего запроса в строке 20 вашей строки удаления. Надеюсь, поможет.

include_once('dbconnect.php');
echo "<form action='delete.php' method='post' id = 'deleteForm'>";

$sqlARTICLEQuery = "SELECT * FROM articles where pageId=$paqueryRow[pageId] order by articleId";
$articlequeryResult = mysqli_query($conn,$sqlARTICLEQuery);
while ($articlequeryRow = mysqli_fetch_assoc($articlequeryResult))
{ echo "<input type = 'radio' name = '$articlequeryRow[articleId]' method = 'post'>".$articlequeryRow['articleId']."&nbsp".$articlequeryRow['articleTitle']."&nbsp";
echo "<input name='ARTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['ARTSubmit'])){
$artDeleteQuery = "DELETE FROM articles where pageId = $paqueryRow[pageId] AND articleId=$articlequeryRow[articleId].";

if(mysqli_query($conn, $artDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}
$sqlTEXTQuery = "SELECT * FROM text where articleId=$articlequeryRow[articleId] order by textId";
$textqueryResult = mysqli_query($conn,$sqlTEXTQuery);
while ($textqueryRow = mysqli_fetch_assoc($textqueryResult))
{
echo "<input type = 'radio' name = '$textqueryRow[textId]' method = 'post'>".$textqueryRow['textId']."&nbsp".$textqueryRow['textTitle']."&nbsp";         //how can I print articles.pageId to match with pages.pageId
echo "<input name='TEXTSubmit' type='submit' value='delete   record' /><br/>";
if (isset($_POST['TEXTSubmit'])){
$textDeleteQuery = "DELETE FROM text where articleId = $articlequeryRow[articleId] AND textId = $textqueryRow[textId].";

if(mysqli_query($conn, $textDeleteQuery)){

echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}echo "<br />"}echo "<br />"}echo "</form>"$conn->close();
?>
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector