0

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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by FlashCreations
0

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