Question : Greater-than/Less-than in sql query by php ... Acceptable for date column ??

I have a backend app that references a client's information against a sql db.

If NO rows are returned from the first query, it runs the second. If both queries return 0 rows, the user may proceed to enter the client into the system.

It IS date specific. Clients (depending on the service they receive from us) are permitted to be entered either once a year or once every 6 months.

The code looks like this:

Here's a little more detailed breakdown.
Client calls out office to check their eligibility.
Our CSA takes a clients information. They must enter at a minimum, last name & social.

Press submit, run the function.

IF the function returns a count value, the client is ineligible.
IF the function returns FALSE, the client is eligible.

HERES MY PROBLEM ::
On the page that post from form, the CSA chooses if the service type is regular or crisis. I have a function that calculates back 6 months if its crisis, and 12 months if its regular and the $datetime variable takes on that value.

When the first query takes place, everything seems to work fine.
When the second query takes place, it returns 0 rows whenever it tries to retrieve anything crisis (6 months) - however - it will retrieve anything thats regular (12 months)

Let me know if you need me to post anything from the database.

BOTH tables are using the DATE column structure in ISO 8601 format.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
function ckEligible($last_name,$first_name,$maiden_name,$social_3,$liheap_type,$datetime){
	
	// Set connection
	GLOBAL $connection;
	
	GLOBAL $output;
	$count=0;
	$output= "<table>";
	
	// Verify Eligibility Against NEW Liheap Table
	$query="SELECT * FROM prodcen_liheap WHERE last_name=\"{$last_name}\" AND social_3=\"{$social_3}\" AND liheap_type=\"{$liheap_type}\" AND datetime>\"{$datetime}\"";
	$results=mysql_query($query,$connection);
	while($row=mysql_fetch_array($results)){
		$count++;
		$output.= "<tr><td width=\"150\">";
		$output.= $count.". ";
		$output.= $row['last_name'];
		$output.= ", ";
		$output.= $row['first_name'];
		$output.= "</td><td width=\"185\">";
		$output.= $row['liheap_type']." assistance";
		$output.= "</td><td width=\"150\">";
		$output.= $row['datetime'];
		$output.= "</td></tr>";
	}  
	
	// Verify Eligiblity Againt OLD Liheap Table
	if($count==0){
		$query="SELECT * FROM prodcen_verify WHERE ";
		if(!empty($last_name)){ $query.="last_name=\"".$last_name."\" AND "; }
		if(!empty($first_name)){ $query.="first_name=\"".$first_name."\" AND "; }
		if(!empty($maiden_name)){ $query.="maiden_name=\"".$maiden_name."\" AND "; }
		$query.="liheap_type=\"{$liheap_type}\" AND datetime>\"{$datetime}\"";
		$results=mysql_query($query,$connection);
		while($row=mysql_fetch_array($results)){
			$count++;
			$output.= "<tr><td width=\"150\">";
			$output.= $count.". ";
			$output.= $row['last_name'];
			$output.= ", ";
			$output.= $row['first_name'];
			$output.= "</td><td width=\"185\">";
			$output.= $row['liheap_type']." assistance";
			$output.= "</td><td width=\"150\">";
			$output.= $row['datetime'];
			$output.= "</td></tr>";
			}
	}
		//Close Table & Return Counted Rows.
		$output.= "</table>";
		return $count;
 }

Answer : Greater-than/Less-than in sql query by php ... Acceptable for date column ??

> I want to find any communities
that is defined by the field BL.CommunityID, which is the same for up to 11 rows?

if that is the design (not really good, but anyhow), what about this start:
1:
2:
3:
4:
5:
6:
7:
  SELECT B.CommunityID, Bld.BudgetDefinitionIDY 
    FROM (SELECT CommunityID FROM LCSInsight_ExtractBudgetLeads GROUP BY CommunityID ) B
    CROSS JOIN LCSInsight_ExtractBudgetLeadsDim Bld
    WHERE NOT EXISTS ( SELECT NULL FROM LCSInsight_ExtractBudgetLeads Bl
                       WHERE Bl.CommunityID = B.CommunityID
                         AND B1.BudgetDefinitionIDY = Bld.BudgetDefinitionIDY 
                     )
Random Solutions  
 
programming4us programming4us