Forum Moderators: coopster
But I need to put in some sort of error if the person choose dates higher than end date in the database,
What I want to do is this, but don´t work of course:
sep_fin is an datecolumn in the database
if ($salida>"sep_fin") {
echo "¡ There are no prices yet!";
}
elseif ($row = mysql_fetch_array($result)){
How to do this?
date, the MAX() [dev.mysql.com] function should work just fine...
$sql = "SELECT MAX(mydate) AS sep_fin FROM table";
$row = mysql_fetch_assoc(mysql_query($sql));
if ($salida>$row['sep_fin']) {
echo "¡ There are no prices yet!";
} elseif ($row = mysql_fetch_array($result)) {
// process
}
$result = mysql_query ("SELECT etc,....
$row = mysql_fetch_assoc($result);
if ($salida>$row['sep_fin']) { echo "¡ There are no prices yet!"; }
elseif ($row = mysql_fetch_array($result)){
Other concerns...
Is the date column in your table indeed of column type
date?
This is the current code that works perfect:
$sql = "SELECT MAX(sep_fin) AS max, MIN(baja_inicio) AS min FROM propiedad";
$rows = mysql_fetch_assoc(mysql_query($sql));
if ($salida>$rows['max']) { echo "¡ There are no prices yet for choosen dates!"; }
if ($salida<$rows['min']) { echo "¡ You choosen an past date!"; }
elseif ($row = mysql_fetch_array($result)){
Below is what I want to do, even though the code is crazy :) lol
just to clarify...
$sql = "SELECT baja_inicio AND baja_fin AND media_inicio AND media_fin and enero_inicio AND enero_fin and alta_inicio AND alta_fin and
abril_inicio AND abril_fin and verano_inicio AND verano_fin and sep_inicio AND sep_fin FROM propiedad";
$rows = mysql_fetch_assoc(mysql_query($sql));
if ($salida>$rows) { echo "¡ There are no prices yet for choosen dates!"; }
if ($salida<$rows) { echo "¡ You choosen an past date!"; }
elseif ($row = mysql_fetch_array($result)){
i.e I want to say that if $salida is < or > than all of these columns in the database to display an error message,
could be done?