Dinamik sayaç değişkeni geçirmeden

1 Cevap php
'view_act.php' file

<?php


  $query = mysql_query('select * from activities');
   $check=mysql_num_rows($query);
  if($check==0)
   { 
   echo "No enteries found ";
   }

  else
  {  
     static $counter;
     echo '<table border="1" cellpadding="5" cellspacing="5" align="center">

      <tr>

      <th><font color="#FF9900">ACTIVITY NAME</font></th>
      <th><font color="#FF9900">ACTIVITY UPDATE</font></th>
     </tr>';
     while($row=mysql_fetch_array($query))
     { $counter++;


           echo '<tr>';

           echo '<td width=231>
      <form action="update_act.php" method="POST">';

       echo "<center><font color=\"#CC9900\">".$row['act_name']."</center>";


      echo "</td>
      <td width=231>";
      echo "<center>".'<font color="#CCCCCC"><input type="submit" name="edit"                                 value="edit"></center>';
      echo '<input type="hidden" name="act_name'.$counter.'" value="'.$row['act_name'].'" />';
      echo '<input type="hidden" name="count" value="'.$counter.'" />';


      echo "</td>
       </tr>";
     }
     echo "</form>";
    echo "</table>";


  }         

 ?> 


'update_act.php' file

 <?php
      $count=$_POST['count'];
  echo "Old Activity Name : ". $_POST["act_name".$count];
  echo '<br/>Enter new activity name :
       <form action="update_act.php" method="post">
          <input type="text" name="aname">
     <input type="submit" name="submit">'; 
  ?>

İşte tablo getirilen veriler, her Aktivite Adı için farklı bir ad counter.But tarafından verilen bu yüzden formu sayfasına gönderildiğinde burada sorun düzenleme düğmeye farklı bir isim ile güncellenmelidir update_act.php son değeri Etkinlik Adı herhangi bir satırın eski Etkinlik Adı değeri tablo 'act_name' son değeri her time.So geçirilir. herhangi Etkinlik Adı sayacın uygun değer geçmek için bana yardım edin.

1 Cevap

Bu bir felaket.

Bir Tablodan belirli satırları tanımlamak istiyorsanız o birincil anahtar veya benzersiz bir vekil anahtar üzerinde yapılmalıdır. , Bir sayaç / rownum / ofset kullanmak ASLA asla.

  • (Bazı benzersiz anahtarı) bir ORDER BY zorlamak bile.

  • Eğer seçme ve güncelleştirme (onlar zaten ayrı sayfalarında meydana eğer imkansız olduğu) kapsayan bir işlem yok bile

C.