Page 4 of 4

Posted: Wed May 25, 2005 8:20 am
by mohson
I thought this would be the correct thing to do:

Code: Select all

WHERE datecontactagain LIKE '$var1."-".$var3."-".$var2;'";

Posted: Wed May 25, 2005 8:22 am
by JayBird
you've already done that at the begining of the script...no need to do it again, just use the other variable

Posted: Wed May 25, 2005 8:22 am
by mohson
this will compare the variables entered wont it?

Code: Select all

WHERE datecontactagain LIKE '$var1."-".$var3."-".$var2;'";

Posted: Wed May 25, 2005 8:24 am
by JayBird
before i pull my hair out

here...

Code: Select all

WHERE datecontactagain LIKE '$datecontactagain'";
:roll:

Posted: Wed May 25, 2005 8:30 am
by mohson
sorry pimp, I worked that out didnt get the chance to get back to you, I havent tested it yet one sec, damn Ive gotto say thank you for the way in which you answer my questions, Its so much more challenging then just giving the answers. only thing is im worried that people wont have the time to explain thanks Mark appreciate it.

Posted: Wed May 25, 2005 8:39 am
by mohson
Mark,

I have added a new record with the contact again date set to todays date.
25th of May 2005

When I search the database for this date my table displays fine but it doesnt find any results.

heres my code:

Code: Select all

$var1 = $_POST["datecontactagain_Year"];
$var2 = $_POST["datecontactagain_Day"];
$var3 = $_POST["datecontactagain_Month"];  
$datecontactagain = $var1."-".$var3."-".$var2;

foreach($HTTP_POST_VARS as $varname => $value)
        $formVars[$varname]=$value;

$query = "SELECT 
		o.org_id,o.web_url,
		p.person_id,p.org_id,p.salutation,p.firstname,p.surname,
		p.organisation,p.role,p.address1,p.address2,p.city,
		p.postcode,p.telephone,p.mobile,p.fax,p.dateoflastcontact,
		p.datecontactagain,p.notes,p.email, 


		DATE_FORMAT(dateoflastcontact, '%M/%Y') 
		AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%M/%Y') 
		AS datecontactagain 

		
		FROM people p LEFT JOIN organisations o
     		ON o.org_id = p.org_id

		WHERE datecontactagain LIKE '$datecontactagain'";


$result = mysql_query($query);

Posted: Wed May 25, 2005 8:45 am
by JayBird
it is becuase you have reformatted the date in the query ont his line

Code: Select all

DATE_FORMAT(dateoflastcontact, '%M/%Y') AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%M/%Y') AS datecontactagain
i would have done this

Code: Select all

DATE_FORMAT(dateoflastcontact, '%M/%Y') AS dateoflastcontact_formatted, DATE_FORMAT(datecontactagain, '%M/%Y') AS datecontactagain_formatted

Posted: Wed May 25, 2005 8:52 am
by mohson
thanks tried that as well and just to make doubly sure added a new record with todays date then searched todays date again and still no results

Posted: Wed May 25, 2005 8:54 am
by JayBird
change WHERE to = in this line

Code: Select all

WHERE datecontactagain LIKE '$datecontactagain'";
(still with the previous changes i told ya)

Posted: Wed May 25, 2005 8:59 am
by mohson
do you mean change the LIKE TO =?

Posted: Wed May 25, 2005 9:00 am
by mohson
sorry, obviously you mean that, one sec

Posted: Wed May 25, 2005 9:03 am
by JayBird
mohson wrote:do you mean change the LIKE TO =?
whopps, that is what i meant :lol:

Posted: Wed May 25, 2005 9:03 am
by mohson
Yep Mark that has worked fine brilliant, only thing is I had to remove the '_formatted' because its displayling the date like this '2005-05-25' so I changed back to before and it works fine.

I think Ill give you a break now, thanks agin MENTOR PIMPSTER.

Posted: Wed May 25, 2005 9:06 am
by JayBird
Cool :D

lesson over...for now