Jump to content

A little help Please


divinedesigns1

Recommended Posts

ok, im recreating my website into a dymanic website "its a static website atm" and im stuck on displaying the amount of messages i get from the contact form when try my code it display there was 0 msg when there was 2 msg this is my code

$date = date('Y, m d');$msg = mysqli_query($con, "SELECT * FROM contact WHERE date='$date'") or die('Error: ' . mysqli_error($con));$nums = mysqli_num_rows($msg);if($nums > 0){echo $nums;}

and this is the structure in my dbid int(11)fn varchar(255)em varchar(255)country varchar(255)city varchar(255)others textdate date 0000-00-00but its not working atm, so can someone point me in the right direction by hinting me on my mistake

Link to comment
Share on other sites

Format the date like it shows, 0000-00-00.
ok ill try that
$date = date('Y, m d');

displays as: 2012, 10 11

no errors
Link to comment
Share on other sites

I meant maybe why you're not getting any results is because $date is being displayed as 2012, 10 11 when the date column contains dates that display like this instead: 2012-10-11. So try this:

$date = date('Y-m-d');

Edited by Don E
Link to comment
Share on other sites

$date = date('Y, m d');

displays as: 2012, 10 11

yeah i though that would work, since its 0000-00-00 in the db
I meant maybe why you're not getting any results is because $date is being displayed as 2012, 10 11 when the date column contains dates that display like this instead: 2012-10-11. So try this:
$date = date('Y-m-d');

alrite ill try that one see sup
Link to comment
Share on other sites

ok i figure out why it wasnt working, for some reason, $date(Y-m-d) was displaying 2012-10-12 once i minus "a day" from the date() it displays 2012-10-11 which is the correct date, thanks for the help guys

Link to comment
Share on other sites

date has second parameter which takes timestamp as its parameter. by default it is current timestamp. so it is showing you the correct date

Link to comment
Share on other sites

date has second parameter which takes timestamp as its parameter. by default it is current timestamp. so it is showing you the correct date
oh alrite
It's using the time settings on the server, whatever that is set to.
that explains why i kept getting the wrong date thanks guys
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...