I am trying to update several rows in the database using mysql statement. My code is as follows.

<?php

 $query = mysql_connect("localhost","root","toor");
  mysql_select_db("busticket",$query);
 $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"<tr><td><input type='submit' name='submit' Value='Validate Tickets'></td></tr>";


 if(isset($_POST['submit']))
{
    if(is_array($_POST['name']))
    {
        $qry = "UPDATE ticket_reservation SET validate_status='Yes' WHERE id IN (".implode(',', $_POST['name']).")";
       // echo $qry; // For checking the generated sql statement; can be removed
        mysql_query($qry);
    }
}

?>
</table>
</form>

My code is not working....

My code is not working

What exactly is not working? Any errors? If you echo the query, what do you see?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.