I'm creating a movie rental site and need to set the availibility of each movie. If its available, the user needs to be able to rent it, if it isnt they need to be told so. In the admin section the availibility of the movie needs to be set.

Now im guessing I need to add a column in the the database table 'availibility' and then link to that via a checkbox? If its checked the user can rent it, if not they get a message or something saying the film is unavailable?

What is the code to enter checkbox data into a database?

Well you could create a form and when the admin submits it, update the movie status with a MySQL query:

status.php

<html>
<head> 
<title>Rental Demo - Created By PhpMyCoder</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
  if($_POST['movie1']==1) mysql_query("UPDATE movies SET available='1' WHERE name='movie1'");
  else mysql_query("UPDATE movies SET available='0' WHERE name='movie1'");
}
?>
<form action="status.php" method="post">
<?php  if(mysql_num_rows(mysql_query("SELECT name FROM movies WHERE name='movie1' AND available='1'"))==1): ?>
Movie Name <input type="checkbox" name="movie1" value="1" checked>
<?php else: ?>
Movie Name <input type="checkbox" name="movie1" value="1">
<?php endif; ?>
<input type="submit" value="Set Movie Status">
</form>
</body>
</html>
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.