we use the code below to filter strings based on selected from and to date.
we can successfully filter and display the results.
Php
if (isset($_POST['post_at']) && $_POST['post_at'] != '') { $orderFromDate = $_POST['post_at'] . " 00:00:00 "; } else { $orderFromDate = ''; } if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '') { $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 "; } else { $orderToDate = ''; } function getDesignerCollection() { if (isset($_POST['post_at']) && $_POST['post_at'] != '') { $orderFromDate = $_POST['post_at'] . " 00:00:00 "; } else { $orderFromDate = ''; } if (isset($_POST['post_at_to_date']) && $_POST['post_at_to_date'] != '') { $orderToDate = $_POST['post_at_to_date'] . " 23:59:59 "; } else { $orderToDate = ''; } $accountType = $rows['type']; if ($accountType == "admin") { if ($orderFromDate != '') $order->addFieldToFilter('created_at', array( 'gteq' => $orderFromDate )); if ($orderToDate != '') $order->addFieldToFilter('created_at', array( 'lteq' => $orderToDate )); }
the form
<form name="frmSearch" method="post" action=""> <input type="text" placeholder="From Date" id="post_at" value="<?php if ($orderFromDate != '') { $newPostStartDate = date('Ym-d', strtotime($_POST['post_at'])); echo $newPostStartDate; } ?>" name="post_at" /> <input type="text" placeholder="To Date" id="post_at_to_date" value="<?php if ($orderToDate != '') { $newPostEndDate = date('Ym-d', strtotime($_POST['post_at_to_date'])); echo $newPostEndDate; } ?>"name="post_at_to_date" /> <input type="submit" name="search" value="search" id="searchButton"> <input type="button" value="Reset" id="clear-dates"> </form>
JQuery
jQuery.datepicker.setDefaults({ showOn: "button", buttonImage: "assets/img/datepicker.png", buttonText: "Date Picker", buttonImageOnly: true, dateFormat: 'yy-mm-dd' }); $(function() { $("#post_at").datepicker(); $("#post_at_to_date").datepicker(); });

now we want to display how many rows are selected. if the result is similar to the previous image, we want to display "rows: 1". I am very new to php and I tried under the code but didn't display anything:
$link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if ($result = mysqli_query($link, "SELECT entity_id , created_at FROM sales_flat_order ORDER BY Name")) { /* determine number of rows result set */ $row_cnt = mysqli_num_rows($result); printf("Result set has %d rows.\n", $row_cnt); /* close result set */ mysqli_free_result($result); }
change
now we want to display the number of rows displayed. , so we tried to make the code below. its display as shown below. its display is "rows = 3" . because it considers the column "entity_id" of the table "sales_flat_order" . but I want "rows: 9" since you can see 9 rows in the image.


require_once '../../app/Mage.php'; Mage::app(); // specify the date picker date-format $format = 'Ym-d'; // if posted data are not empty if(!empty($_POST['post_at']) && !empty($_POST['post_at_to_date'])) { if (!empty($_POST['post_at'])) { $dateFrom = DateTime::createFromFormat($format, $_POST['post_at']); } if (!empty($_POST['post_at_to_date'])) { $dateTo = DateTime::createFromFormat($format, $_POST['post_at_to_date']); } // Get the resource model $resource = Mage::getSingleton('core/resource'); // Retrieve the read connection $read = $resource->getConnection('core_read'); // MySQL query $query = 'SELECT entity_id, created_at, dproduct_id FROM sales_flat_order WHERE created_at BETWEEN :fromdate AND :todate ;'; // Bind MySQL parameters $binds = array( 'fromdate' => $dateFrom->format('Ymd H:i:s'), 'todate' => $dateTo->format('Ymd H:i:s') ); // Execute the query and store the results in $results $results = $read->fetchAll($query,$binds); echo "rows : ".count($results); echo "<br>"; print_r($results); } else { echo "error you have not specified any dates"; }
full code: http://pastebin.com/hMUEusvb