i think i know what you are talking about and if i dont give the right files please let me know

the table dump im assuming is the .sql

there is a csv file thats also got some data but there isnt much, sorry about that, ill make more if u need it.

also i just wanted to say thank you for all of your help, i honestly would have given up on this already so thanks again.

In the export I can see the date as 10/07/2014. My guess is that this is causing the issue. Try:

DATE_FORMAT(NOW(),'%d/%m/%Y')

no change :< has this been removed or something as a feature, i dont understand how this isnt working anymore, maybe we have to use datetime format, idk i feel like im rambling 0.o

Working with a date column is much easier than a date stored as a varchar. If you can change it, it would be a plus.

do you mean just select the date field in the database and use that

ok i changed it but im still getting the same result, i changed the date column to a date format, is there anything else i can do?

ok i started to think maybe i can get the date range in an if statement rather than the sql string, and it worked, but its not limiting the date range its just printing everything out, i think this could work but im not sure whats wrong with it.

// Get Records from the table

    $current = new DateTime(); // Today
    //echo $current->format('m/d/Y'); // echos today! 
    $contractDateBegin = new DateTime($b);
    $contractDateEnd  = new DateTime($e);

    while ($row = mysql_fetch_array($result)) 
    {
        if (($current >= $contractDateBegin) && ($current <= $contractDateEnd))
        {
            for ($i = 1; $i < $columns_total; $i++) {
                $output .='"'.$row["$i"].'",';
            }
        }
        $output .="\n";
    }

thats the new while statement, and the new sql statement is this

$sql = "SELECT * FROM usernumdata";

i can happily say that i dont need asistence with this problem anymore, i did apply my solution in probably the worst way but it works and thats what matters, i can improve everything at my leisure and thats what i wanted all along, and id be happy to post my solution here for others when they run into problems.

<!-- This is the export by date button -->
</form>
<form action="export.php" >

<div style="width:100%;" class = "export"> 
<div class="alert alert-info">
&nbsp
<?php echo "Export By Date e.g. From 2014-06-27 Too 2014-07-01";?>

</div>
<br>
<span style="white-space: nowrap;">


<?php echo "From:" ?>&nbsp
<input type="text" name="b" class="tcal" id="text" />&nbsp
<?php echo "To" ?>&nbsp
<input type="text" name="e" class="tcal" id="text" />&nbsp


<div class = "exportbtn"> 
<input type="submit" class="btn btn-info" value="Export to CSV file" name="export">
</div>

</span>

</div>
</form>

This is the html for using and accessing my export, which my export.php is the export file by date.

here is the code i used to only print to csv the selected date range that was made by the user in the html file.

$output = "";

$sql = "SELECT * FROM usernumdata";

$result = mysql_query($sql, $con) or die($sql . '<br/>' . mysql_error());
$columns_total = mysql_num_fields($result);

// Get The Field Name

for ($i = 1; $i < $columns_total; $i++) 
{
    $heading = mysql_field_name($result, $i);
    $output .= '"'.$heading.'",';
}
$output .="\n";


// Get Records from the table


$contractDateBegin = date('m/d/Y', strtotime($_GET['b']));
$contractDateEnd = date('m/d/Y', strtotime($_GET['e']));

while ($row = mysql_fetch_array($result)) 
{
    if (($row['date'] >= $contractDateBegin) && ($row['date'] <= $contractDateEnd))
    {
        for ($i = 1; $i < $columns_total; $i++) {
            $output .='"'.$row["$i"].'",';
        }
        $output .="\n";
    }

}

This code works perfectly, and while im sure some would ask why in the world i split the files up when i could have set this one to export all is neither values came up true, well i tried that but then once i did it would print all values in the table regardless, and that was a problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.