Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    5

    Unanswered: problem with delete from...........

    Hello everyone:

    I'm new here and need your help. I'm trying to create an application php-mysql to show news. The problem that I have is that the script that allows me to delete the news always delete the last one although presses on third, the fourth or anyone.

    This it is script:

    Code:
    <?
    if (isset($_GET['proceso'])){
    echo $_GET['proceso']."<br>";
    }
        $SQL = " SELECT * FROM pw_news ";
        $retid = mysql_db_query($BaseDatos, $SQL, $link);
        if (!$retid) { echo( mysql_error()); }
        else {
            echo ("<P><TABLE border=1 CELLPADDING=4><tr><td colspan=2><b>selecciona la Noticia a borrar</b></td></tr>\n");
            while ($row = mysql_fetch_array($retid)) {
                $titulo = $row["titulo"];
                $id = $row["id"];
    
                echo ("<TR>");
                echo ("<TD>$titulo</TD>\n");
                echo ("<TD><A HREF=\"bnews.php?action=admin&id=$id\">Eliminar</A></TD>");
                echo ("</TR>");
            }
            echo ("</TABLE>");
        }
        ?>
        <?
        if($_GET['action']=="admin")
            {
            require ("datos.inc.php");
            require ("conexion.inc.php");
       mysql_query("DELETE FROM  pw_news WHERE id=$id limit 1",$link);
       $resultMenuUrlName = "bnews.php";
        echo "<BODY bgcolor=ffffff> <center><hr><br><b>El campo ha sido eliminado correctamente.</b><br> se actualizara la lista en unos segundos<hr></center>";
        echo "<META HTTP-EQUIV=Refresh CONTENT=3;URL=$resultMenuUrlName>";
            };
            ?>
    Somebody can help me?
    Thx

  2. #2
    Join Date
    Jul 2004
    Posts
    69
    mysql_query("DELETE FROM pw_news WHERE id=$id limit 1",$link)

    you sure you need that limit 1 in your statement?

  3. #3
    Join Date
    Jan 2005
    Posts
    5
    Hi Daniel:

    Thanks for your answer. "limit 1" is for making sure that only delete a registry every time. Anyway already I proved without limit 1 and continues always erasing the last registry, not the one that I pulse. I believe that the problem is in the parts in bold and
    Code:
    if($_GET['action']=="admin")
    , But I do not find the form to make work it.

    Thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •