Hi,
I'm trying to improve my limited understanding of php/mysql particularly as we are now undertaking oscomm projects (it helps!)
My wife is designing a villa promotion site at the moment so as a learning exercise I decided to try and build a simple CMS whereby the client can update a calendar showing "free" versus "booked" days for his properties.
I started out with a simple table in mysql with 3 columns (ID, day, status) representing the available days for a month. The idea is that the punter can change the status from "free" to "booked" using a form submission.
The table creation went fine and I managed a simple php file to pull data from the table (days and status) and insert it into a table.
Next bit I'm finding trickier, i.e. the php file to allow changes to the "status" column for particular days as defined in the form fields.
I have this (don't laugh!)
<html>
<head>
<title> Status Admin </title>
</head>
<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="checkbox" name="checkbox1" value="booked">
<input type="checkbox" name="checkbox2" value="booked">
<input type="checkbox" name="checkbox3" value="booked">
<input type="checkbox" name="checkbox4" value="booked">
<input type="checkbox" name="checkbox5" value="booked">
<input type="checkbox" name="checkbox6" value="booked">
<input type="checkbox" name="checkbox7" value="booked">
<input type="checkbox" name="checkbox8" value="booked">
<input type="checkbox" name="checkbox9" value="booked">
<input type="checkbox" name="checkbox10" value="booked">
<input type="checkbox" name="checkbox11" value="booked">
<input type="checkbox" name="checkbox12" value="booked">
<input type="checkbox" name="checkbox13" value="booked">
<input type="checkbox" name="checkbox14" value="booked">
<input type="checkbox" name="checkbox15" value="booked">
<input type="checkbox" name="checkbox16" value="booked">
<input type="checkbox" name="checkbox17" value="booked">
<input type="checkbox" name="checkbox18" value="booked">
<input type="checkbox" name="checkbox19" value="booked">
<input type="checkbox" name="checkbox20" value="booked">
<input type="checkbox" name="checkbox21" value="booked">
<input type="checkbox" name="checkbox22" value="booked">
<input type="checkbox" name="checkbox23" value="booked">
<input type="checkbox" name="checkbox24" value="booked">
<input type="checkbox" name="checkbox25" value="booked">
<input type="checkbox" name="checkbox26" value="booked">
<input type="checkbox" name="checkbox27" value="booked">
<input type="checkbox" name="checkbox28" value="booked">
<input type="checkbox" name="checkbox29" value="booked">
<input type="checkbox" name="checkbox30" value="booked">
<input type="checkbox" name="checkbox31" value="booked">
<input type="submit" name="Submit" value="submit">
</form>
<?php
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'root', 'smeg');
if (!$dbcnx) {
die( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
}
// Select the calendar database
if (! @mysql_select_db('calendar') ) {
die( '<p>Unable to locate the calendar ' .
'database at this time.</p>' );
}?>
<?php $checkbox = $_POST['checkbox1'];
$sql = "UPDATE months SET
Status='$checkbox'
WHERE ID=1";
if (@mysql_query($sql)) {
echo('<p>Status has been updated.</p>');
} else {
echo('<p>Error updating status: ' .
mysql_error() . '</p>');
}
?>
</body>
</html>
I can see why this is only letting me update one row represented by "checkbox1" but I'm damned if I can work out how to update selected fields.
This is probably a poor way of attempting it but hey - I have to start somewhere!
Advice for a php "noob" welcomed please.
cheers
sponna![]()




Bookmarks