0

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....

Edited by blueshiftdani: Deleted some unnecessary lines

2
Contributors
1
Reply
5
Views
2 Years
Discussion Span
Last Post by pritaeas
0

My code is not working

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

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.