Database queries
Hi I'm new to Dreamweaver and building websites. I am building a website where in a form you enter a date and select a name from an select list then press the submit button. What I want is to send a query to my database and check to see if the name you selected is available on that date, and if so post on the same form that the person is either available on that date or not.
I have created my database and I am connected to it. I have created a recordset, with a preset name and date, and when I test my sql it shows one record from my database.
I hope I have enough info here and I am not to confusing.
Thanks in advance for any help.
Here is a copy of the function that was created when I created my recordset
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connEMJEvents, $connEMJEvents);
$query_rsAvailability = "SELECT * FROM `Bookings` WHERE `speaker` = 'John Doe' AND `date` = '2011-04-09'";
$rsAvailability = mysql_query($query_rsAvailability, $connEMJEvents) or die(mysql_error());
$row_rsAvailability = mysql_fetch_assoc($rsAvailability);
$totalRows_rsAvailability = mysql_num_rows($rsAvailability);
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
}
}
?>
So on my form I have
textbox --- where you enter date
option list -- where you select a name
submit button
some text where i want to change to available or not abavailable
What I don't know is what to set the action of my form to and how to have my form select the date and name and query the database with that information then change the label to show available or unavailable as a result of the query.
Thanks
Winrol
