lundi 7 septembre 2015

Update only checked rows php mysql

I am trying to update only checked rows in the table but nothing is happening Here is my code

<?php
//database connect select
$result=mysql_query("Select * from ticket_reservation WHERE 
validate_status='No'") or die(mysql_error());
while($row=mysql_fetch_array($result))
{
echo "<tr><td><input type='checkbox' id='name' name='name[]'value=".$row['id']."</td><td>".$row['userid']."</td><td>".$row['busid']."</td><td>".$row['numberofseats']."</td></tr>";
           echo "<br>"; 
 }
     ?>

    <input type="submit" Value="Validate Tickets">
    </table>

And here is the code for update query I can't figure out what is going wrong

if(isset($_POST['submit']))
{
 if(is_array($POST['name']))
 {
 $name=$_POST['name'];
 foreach($_POST['name'] as $x)
 {
 $qry="UPDATE ticket_reservation set     validate_status='Yes' " ;
 mysql_query($qry);
 }     
  }
   }




Aucun commentaire:

Enregistrer un commentaire