在一个页面中实现增删改查功能,页面上边是一个表单做录入,下面是一个数据列表,查询出来的每一行最后2列是“删除”和“修改” 链接,现在再点击修改链接的时候竟然删除了记录,页面传进来的参数明明是"update"请高手指点,本人刚刚接触PHP,谢谢!下面是完成的页面
<html>    
                                                       
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">                                                              
 <head>
 
<title>                                                              
   数据管理                                                    
</title>                                                                     
<body background="bg.gif">                                                                 
                                                            
                                                                     
<?php                                                                
$db = MySQL_connect("localhost", "root");      MySQL_select_db("football",$db);    
    mysql_query("set names GB2312");   

 $id  = $_GET['id'];
 $act = $_GET['do']; 
 
                             
                                       
if ($save)                                                         
   {                                                                 
    $sql = "update mymatch
        set  league    = '$league',
     matchtime = '$matchtime',
 host      = '$host',
 visit     = '$visit',
 type      = '$type',
 let       = '$let',
 tuijie    = '$tuijie' ,
 bifen     = '$bifen',
 result    = '$result',
 star      = '$star',
 lltype    = '$lltype',
 tzje      = '$tzje',
 opentime  = '$opentime' 
 where id = $id ";
    $result = MySQL_query($sql);                                     
                                     
   }      
   
   
if ($submit)                                                         
   {                                                                 
    $sql = "INSERT INTO mymatch(league,matchtime,host,visit,type,let,tuijie,bifen,result,star,lltype,tzje,opentime)           
             VALUES ('$league','$matchtime','$host','$visit','$type','$let','等待公布','--','--','$star','$lltype','$tzje', '$opentime')";
    $result = MySQL_query($sql);                                     
                                     
   }         
   
  echo $act ;
     
 if ($act = 'update')                                                         
      {                                                                 
        $sql = "select * from mymatch where id = $id ";
    $result1 = MySQL_query($sql);   
    while ($myrow = MySQL_fetch_row($result1))                           
         {                            
     $league    = $myrow[1];
 $matchtime = $myrow[2];
 $host      = $myrow[3];
 $visit     = $myrow[4];
 $type      = $myrow[5];
 $let       = $myrow[6];
 $tuijie    = $myrow[7];
 $bifen     = $myrow[8];
 $result    = $myrow[9];
 $star      = $myrow[10];
 $lltype    = $myrow[11];
 $tzje      = $myrow[12];
 $opentime  = $myrow[13];                                  
                                     
          }    
     }
 
   echo $act ;
     if ($act = 'delete')                                                         
   {                                                                 
    $sql1 = "delete from mymatch where id = $id ";
    $result = MySQL_query($sql1);                                     
                                     
   } 
                                                                       
   
  ?>                                                                 
                                                                     
  <P>                                                                
                                                                     
  <h2 align=left>                                                    
                                                   
  </h2>                                                              
                                                                     
<form method="post" action="">
  <table width="271" border="1" align="center">
    <tr>
      <td width="84">联赛</td>
      <td width="171"><input name="league" type="text" size="20" value="<?php echo $league;?>"/></td>
    </tr>
    <tr>
      <td>比赛时间</td>
      <td><input type="text" name="matchtime" value="<?php echo $matchtime;?>"/></td>
    </tr>
    <tr>
      <td>类型</td>
      <td><select name="type" value="<?php echo $type;?>" >
        <option value="亚盘" selected>亚盘</option>
        <option value="大小">大小</option>
        <option value="卖(受注)">卖(受注)</option>
      </select></td>
    </tr>
    <tr>
      <td>主队</td>
      <td><input type="text" name="host" value="<?php echo $host;?>"/></td>
    </tr>
    <tr>
      <td>让球</td>
      <td><input type="text" name="let" value="<?php echo $let;?>"/></td>
    </tr>
    <tr>
      <td>客队</td>
      <td><input type="text" name="visit" value="<?php echo $visit;?>"/></td>
    </tr>
    <tr>
      <td>推荐</td>
      <td><input type="text" name="tuijie" value="<?php echo $tuijie;?>"/></td>
    </tr>
    <tr>
      <td>级别</td>
      <td><select name="star" value="<?php echo $star;?>">
        <option value="4星">4星</option>
        <option value="5星">5星</option>
      </select></td>
    </tr>
    <tr>
      <td>投注额</td>
      <td><input name="tzje" type="text" size="10" value="<?php echo $tzje;?>"/></td>
    </tr>
    <tr>
      <td>公开时间</td>
      <td><input type="text" name="opentime" value="<?php echo $opentime;?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
   <input type="Submit" name="submit" value="发布">
   <input type="Submit" name="save" value="更新">
  </td>
    </tr>
  </table>
</form>      <?php  $result = MySQL_query("SELECT id,league,matchtime,type,host,let,visit,tuijie,bifen,result FROM mymatch",$db);
   
   echo "<table border=1 align = 'center'>\n";
   echo "<tr>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>序号</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>联赛</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>比赛时间</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>推介类型</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>主队</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>盘口</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>客队</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>推介</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>比分</td>"; 
       echo "<td  align = 'center' bgcolor='#FF0000' class='STYLE15'>结果</td>";                          
   echo "</tr>\n";                                                  
       
       while ($myrow = MySQL_fetch_row($result))                           
   {                                                                
     printf("<tr><td align = 'center'>%s</td>", $myrow[0]);
         printf("<td align = 'center'>%s</td>", $myrow[1]); 
         printf("<td align = 'center'>%s</td>", $myrow[2]);        
         printf("<td align = 'center'>%s</td>", $myrow[3]);  
         printf("<td align = 'center'>%s</td>", $myrow[4]);        
         printf("<td align = 'center'>%s</td>", $myrow[5]); 
         printf("<td align = 'center'>%s</td>", $myrow[6]);        
         printf("<td align = 'center'>%s</td>", $myrow[7]); 
         printf("<td align = 'center'>%s</td>", $myrow[8]);
 printf("<td align = 'center'>%s</td>", $myrow[9]);
 
 printf("<td align = 'center'><a href=add.php?id=".$myrow[0]."&do=delete>%s</a></td>","删除");
 printf("<td align = 'center'><a href=add.php?id=".$myrow[0]."&do=update>%s</a></td>","修改");

 
 echo "</tr>\n";    
   }   
?>                                                    
                                                                     
                                                                
                                                                     
</body>                                                              
                                                                     
</html>