<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[controllo dati esistenti prima di insert]]></title><description><![CDATA[<p dir="auto">&lt;?php require_once('Connections/camere.php'); ?&gt;<br />
&lt;?php<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")<br />
{<br />
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;</p>
<p dir="auto">switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}</p>
<p dir="auto">$editFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />
}<br />
if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "form1")) {<br />
$insertSQL = sprintf("INSERT INTO stato_pren (numero_camere, cognome, nome, indirizzo, telefono, fax, email, data_prenotazione, data_arrivo, data_partenza, stato) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",<br />
GetSQLValueString($_POST['numero_camere'], "text"),<br />
GetSQLValueString($_POST['cognome'], "text"),<br />
GetSQLValueString($_POST['nome'], "text"),<br />
GetSQLValueString($_POST['indirizzo'], "text"),<br />
GetSQLValueString($_POST['telefono'], "text"),<br />
GetSQLValueString($_POST['fax'], "text"),<br />
GetSQLValueString($_POST['email'], "text"),<br />
GetSQLValueString($_POST['data_prenotazione'], "date"),<br />
GetSQLValueString($_POST['data_arrivo'], "date"),<br />
GetSQLValueString($_POST['data_partenza'], "date"),<br />
GetSQLValueString($_POST['stato'], "text"));</p>
<p dir="auto">mysql_select_db($database_camere, $camere);<br />
$Result1 = mysql_query($insertSQL, $camere) or die(mysql_error());<br />
$insertGoTo = "cercastatopren.php";<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&amp;" : "?";<br />
$insertGoTo .= $_SERVER['QUERY_STRING'];<br />
}<br />
header(sprintf("Location: %s", $insertGoTo));<br />
}<br />
mysql_select_db($database_camere, $camere);<br />
$query_Recordset1 = "SELECT * FROM stato_pren WHERE stato_pren.data_arrivo&lt;='$data_partenza' AND stato_pren.data_partenza&gt;='$data_arrivo'";<br />
$Recordset1 = mysql_query($query_Recordset1, $camere) or die(mysql_error());<br />
$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br />
$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br />
?&gt;</p>
<p dir="auto">Vorrei aggiungere un cotrollo di inserimento,se la camera 1 con la data_arrivo e la data_partenza gia esiste mi deve dare camera gia prenotata,ma non riesco a  inserire questo controllo.<br />
grazie<br />
ciao<br />
<img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/ad0a1f8d-b404-40e4-a46a-e563b14044da-dho.gif?v=2190ae3dadd" class="not-responsive emoji emoji-customizations emoji--arrabbiato" style="height:1.4em;width:auto;vertical-align:middle" title=":x" alt="" /></p>
]]></description><link>https://dev.connect.gt/topic/11310/controllo-dati-esistenti-prima-di-insert</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 04:29:50 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/11310.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 May 2006 13:27:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to controllo dati esistenti prima di insert on Thu, 01 Jun 2006 06:57:39 GMT]]></title><description><![CDATA[<p dir="auto">risolto,<br />
Il codice che ho postato va bene, ho solo aggiunto il controllo all'inizio<br />
ciao e grazie<br />
<img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f60e.png?v=2190ae3dadd" class="not-responsive emoji emoji-android emoji--sunglasses" style="height:1.4em;width:auto;vertical-align:middle" title="8)" alt="😎" /></p>
]]></description><link>https://dev.connect.gt/post/328326</link><guid isPermaLink="true">https://dev.connect.gt/post/328326</guid><dc:creator><![CDATA[leoneweb]]></dc:creator><pubDate>Thu, 01 Jun 2006 06:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to controllo dati esistenti prima di insert on Thu, 01 Jun 2006 06:54:03 GMT]]></title><description><![CDATA[<p dir="auto">ho dato un'occhiata veloce al tuo codice e mi pare che il controllo non funzioni molto bene.</p>
<p dir="auto">per capire bene come costruire questa query devi prendere un pezzo di carta e lavorare con le stanghette.</p>
<p dir="auto">disegna la linea temporale e fai due stanghette che indicano il periodo di camera prenotata e poi prova tutte le combinazioni possibili e vedi se il tuo controllo le include o meno (attualmente no).</p>
<p dir="auto">le combinazioni possibili sono che la data di inizio sia precedente al periodo già prenotato ma che la data di fine cada all'interno.</p>
<p dir="auto">che tutte due le date cadano all'interno del periodo già prenotato</p>
<p dir="auto">e che solo la data di inizio cada all'interno mentre quella di fine sia dopo il perido.</p>
<p dir="auto">una volta fatte tutte le possibilità cerchi di ricostruire la condizione where <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=2190ae3dadd" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/328320</link><guid isPermaLink="true">https://dev.connect.gt/post/328320</guid><dc:creator><![CDATA[tymba]]></dc:creator><pubDate>Thu, 01 Jun 2006 06:54:03 GMT</pubDate></item></channel></rss>