Hi,
I am very new to PHP but am learning fast, however I have hit a bit of a stumbling block, basically I have a Holiday Villa website I am making and the user can book a holiday accrording to the date month and the year and can choose between the different villas there are around 25, but basically what I don't want to happen is people booking the same villa on the same day, of the same week of the same month of the same year so i need to write an IF statement to stop this.
However I am struggling to nail it, in english/very poor basic php I need to say
$table = 'the table I am using'
$query = mysql_query("SELECT 'Villa', 'Day', 'Week', 'Month', 'Year' FROM $table);
$check = mysql_fetch_array($query);
IF ( $_POST (after pressing submit button) 'Villa', 'Day', 'Week', 'Month', 'Year' ) == $query
then echo "Duplicate entry not allowed"; // Basically don't add to database
else if
( $_POST 'Villa', 'Day', 'Week', 'Month', 'Year' ) dosen't match existing record then
$insert = "INSERT 'Villa', 'Day', 'Week', 'Month', 'Year' INTO $table
hopefully somebody can make head or tail of this explanation and help me out.
Cheers