php code to display 1 or 0 based on two dates

table name

holidaymaster

id Date 1 12-04-2015

My form has two filters.

  1. fromdate
  2. todate

If user select FromDate = 01-05-2015 AND Todate = 31-05-2015 then it display all days between fromdate and todate in header.

If Days between fromdate and todate is available..in holiday Master table then it display - - - - to this date other wise display 1.

For ex - 12-04-2015 is available in holiday master table..then it shows - - - below all days in output..

Expected output

name coupondate Days -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 Total A 11-04-2015 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 31 B 12-04-2015 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C 13-04-2015 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 31

below is my sql query which gets name and coupondate from table.

<?php if($_POST && isset($_POST['Submit'])) { if($_POST['fromdate']!='' && $_POST['todate']!='') { $fromdate = $_POST['fromdate']; $todate = $_POST['todate']; $cityname = $_SESSION['Auth']['city']; $formdate_r = DateTime::createFromFormat('d-m-Y', $fromdate); $todate_r = DateTime::createFromFormat('d-m-Y', $todate); $formdate_sql = $formdate_r->format("d-m-Y"); $todate_sql = $todate_r->format("d-m-Y"); $data = $database->getRows("SELECT RE.* FROM receipt_entry RE LEFT JOIN city_master CM ON RE.city_name = CM.id WHERE CM.cityname = :cityname AND RE.coupondate BETWEEN :fromdate AND :todate GROUP BY RE.customer_name",array(':fromdate'=>$formdate_sql,':todate'=>$todate_sql,':cityname'=>$cityname)); } } ?> <tr> <th width="37%">Customer</th> <th width="45%">Coupon Received Date</th> <th width="45%">MonthDays</th> </tr> </thead> <?php foreach($data as $row) { ?> <tbody> <tr> <td><?php echo htmlspecialchars($row['customer_name']); ?></td> <td><?php echo htmlspecialchars($row['coupondate']); ?></td> <td>Need To display 1 or - </td> </tr> <?php }?>

Category:php Views:3 Time:2018-06-11
Tags: php mysql

Related post

  • Displaying error messages based on form data in php 2011-12-13

    I'm trying to create a pretty standard user creation form for a website I'm working on, but my PHP amateur status is preventing me from accomplishing my goal. Essentially what I want to do is have the user fill out a registration form, and then have

  • php code to display none? 2011-05-05

    I'm sure this is fairly simple but I really don't get php is there a way to have the below code to display none if there's no url details entered? <div class="details"> <h3>web</h3> <div>URL: <span><a href="<?=$web

  • parts of my php code is displayed in browser 2011-06-21

    My php code is being displayed in the browser but only after the first echo is called leaving this output in the browser "; while($row=mysql_fetch_array($results,MYSQL_ASSOC)){ echo " ".$row['title']; } echo ""; ?> <?php require('settings.php')

  • PHP Code after '>' Displayed as HTML 2011-07-05

    I am going nuts trying to use PHP to get and insert values into an SQLite database. I haven't even managed to get that far yet! It seems that all the php code after '>' is displayed as html text and I cant understand why. The code is posted below.

  • PHP code to display CSV file with option to remove each line 2011-12-03

    I was able to put together a code to display a CSV file containing a list of emails (each line is an email address) for a newsletter group. I am struggling adding a "remove" function in front of each of those email addresses in case the email is no l

  • PHP Code to display article title in Joomla Featured Blog View Menu Item 2012-03-31

    I am currently developing a Joomla 1.7 website, And I am using J2Store shopping Cart so I have to make make an article for every Product. Then to display I create a Joomla Featured Articles Menu Item for the appropriate Category, my problem is this,

  • display image on a report based on two date 2010-03-29

    I am using sql server 2005 reporting service to generate report base on a database. There are two columns which are datetime type ColumnA and ColumnB. The report would display a KPI image on this report by comparing these two columns.Below is the exp

  • Creating an array with date information based on two dates 2012-04-26

    I created the following array manually (bottom), I wish to create it programmatically using only two strings which can be easily exploded (explode()). $min_date = '2012-03-01 00:00:00'; $max_date = '2012-04-25 00:00:00'; I've already explode() the st

  • Calculating Between Dates based on two dates 2011-01-12

    Say the user specifies these two dates.... Start Date: 2010-12-05 End Date: 2011-01-15 If I select December 2010 I should get the folllowing startdate = 2010-12-05 enddate = 2010-12-31 Select January 2011 then startdate = 2011-01-01 enddate = 2011-01

  • php code being displayed in browser 2012-01-23

    I have written php script for user login but instead of displaying the result the whole script is being displayed.I have given a .php file link as an action for the login form. I am using xampp with php and mysql running do I need anything else? the

  • php code to display Product description from other website 2011-04-09

    I need to integrate my prestashop website my Ice-cat. Below mentioned is the format to pull data. General format: http://prf.icecat.biz/index.cgi?prod_id=;vendor=;shopname= Example: http://prf.icecat.biz/index.cgi?prod_id=LX.TEQ06.029;vendor=acer;sho

  • Jquery and PHP with Ajax to compare inputs based on two matrices 2011-05-01

    I have a little problem with multiple comparing values with 2 matrices. I have an HTML table: <table style="border:0px solid;" border="0" class="tema_d_tabel1"> <tr><td>A</td><td>:</td><td><input type="tex

  • two sets of same php code with same version working differently on two different servers? 2011-06-03

    I made a class that converts a string of text into a png image and uploads on the server: http://testing.mehhh.org/php/png.php (you can view php source on the page) http://testing.mehhh.org/php/phg.php <-- shows php version this one works great. n

  • How can you display text inonecell based on a date range in aanother? 2013-10-21

    For example: If Cell 1 date is 1/1/2014<4/1/2014, tthen display Q1 in Cell 2 For example: If Cell 1 date is 4/1/2014<7/1/2014, tthen display Q2 in Cell 2 For example: If Cell 1 date is 7/1/2014<11/1/2014, tthen display Q3 in Cell 2 For examp

  • MySQL - Sort on a calculated value based on two dates 2010-05-25

    I have the following problem that needs to be solved in a MySQL query: Fields info - textfield date1 - a date field date2 - a date field offset1 - a text field with a number in the first two positions, example "10-High" offset2 - a text field with a

  • Sql Server Constraint based on two dates difference 2011-11-24

    I have three columns two are of date types and one is of int The third column stores the difference between two dates in years. What could be the constraint for this? The colums are like: total_years int from_year datetime to_year datetime The total_

  • How to calculate an amount based off two dates? 2014-08-20

    I have tried several formulas and IF statements but I can't seem to make this one work. Basically my spreadsheet looks like this: A1 = January 1, 2011 (Start Date) A2 = January 1, 2012 (End Date) A3 = ?? I would like A3 to equal the amount of days be

  • Number of records per year based on two dates 2015-03-03

    I have a table with member data with one field containing the affiliation date, another containing the disaffiliation date. I would like to know how many members existed in 2008 (or any given year). How would I do this? --------------Solutions-------

  • PHP - issue with display included another .php file 2014-12-01

    I just write simple code to display translated text based on user borowser language. It looks i did something wrong becuase when i use sk.php it display corret SK translate but when it use cs.php it having problem with translate and isntead of any te

  • PHP Code to Insert Text Box Text Into HTML Body 2011-03-10

    I am using the code below: <form> <textarea cols="50" rows="4" name="link"></textarea> <textarea cols="50" rows="4" name="notes"></textarea> <input type="submit" value="Submit"> </form> It creates two text bo

  • JSON encoded data from PHP, doesn't display right when callback from jQuery 2012-03-13

    My HTML/jQuery Code <div id="divResult"></div> function doSearch(str){ var jsonString = str;//$.parseJSON//JSON.stringify(str); $.ajax({ type:'GET', url:'search.php', data:{data:jsonString}, success:function(data){ for( var key in data )

  • How to save the the data processed by this PHP code to a CSV or TXT file 2011-10-20

    I got the following php code that currently process a txt file with data that looks like this per line (Animals > Pet Supplies > Bird Supplies) and I'm reformatting this to use it with my database. What I'd like to do is save the output data to

  • PHP-code blocks in templates loaded in DOMDocument 2011-12-25

    I need to parse HTML-template with DOMDocument. But HTML code may contain PHP-code blocks, for example: <div id="test" data="<?php echo $somevar?>"> </div> When I load this HTML I get error "Unescaped '<' not allowed in attribute

  • difference between two date and display it in input by using php 2012-03-24

    Possible Duplicate: How to calculate the difference between two dates using PHP? I have three input in html. two of them are start date and end date and the third one is to find the difference between them and display the result . here is the inputs:

  • c# datetime value passing based on current date 2010-05-12

    I am trying to fetch records based on two dates from sql server... Select * from table where CreatedDate between @StartDate and @EndDate and i pass 5/12/2010 and 5/12/2010 (ie) fetching records for today... I have 17 records dated 5/12/2010 but none

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.183 (s). 11 q(s)