Hello typedef,
I don't know if I have understand all of your problem, here a way to constroy a SQL with various fields
fpepito
######## http://www.fpepito.org/php/test6.php
[PHP]
<?
if (!isset ($autor)) {
echo "\n";
echo "Autor :
\n";
echo "Text :
\n";
echo "After date :
\n";
echo "Before date :
\n";
echo "\n";
echo "
\n";
echo "\n";
} else {
include "/home/httpd/html/PHP/connect.php";
connect_mysql();
$criteria = "";
if (isset ($autor) && !($autor == "")) {
$criteria .= " autor = '$autor'";
}
if (isset ($text) && !($text == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " desc_pt LIKE '%$text%'";
}
if (isset ($aft) && !($aft == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " data > '$aft'";
}
if (isset ($bef) && !($bef == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " data < '$bef'";
}
if (!($criteria == "")) {
$criteria = "WHERE ". $criteria;
}
$q = "SELECT * FROM fotos_file $criteria";
echo "$q
\n";
$query = mysql_query ($q);
$res = mysql_num_rows($query);
echo "
I found $res element corresponding of your demand";
}
?>
[/PHP]