If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > problem with delete from...........

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-12-05, 11:53
0utKast 0utKast is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 01-13-05, 00:24
Daniel_Johns Daniel_Johns is offline
Registered User
 
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?
Reply With Quote
  #3 (permalink)  
Old 01-13-05, 01:42
0utKast 0utKast is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On