please help ..the date format in my datase is Y-m-d.. now i want to search by date..so in my textbox i need only to type
example:
data in the database: 2014-06-19

in the textbox search i will only type EITHER of the following : 06-19-2014 OR 06192014 (without the - and format is change)

here is the part of my code:

            $searchString=clean(strtoupper($_POST['searchString']));  
            $searchString =date("Y-m-d", strtotime($searchString));



            $query = "SELECT *
                        FROM po
                        WHERE (date = '$searchString') || (date LIKE '%$searchString%')";
            $result = mysql_query($query);
             echo "<table border=1 style='border-collapse: collapse' width=95%>";
             echo "<tr class='tableheader'> 
                    <td>DATE</td> 
                    <td>P.O.#</td>                 
                     <td>SUPPLIER</td>
                     <td>AMOUNT</td>
                     <td>CODE</td>
                     <td></td>
                     <td></td>
                   </tr>";
             while ($records =  mysql_fetch_array($result)){
                    $poDateRetrieved = $records['date'];
                    $poDate=date("m-d-Y", strtotime($poDateRetrieved));

                   echo "<tr> 
                     <td>{$records['poNo']}</td>                 
                     <td>$poDate</td>
                     <td>{$records['supplier']}</td>
                     <td>{$records['tAmount']}</td>
                     <td>{$records['code']}</td>
                     <td><a href=purchaseOrder.php?page=23?&poNo={$records['poNo']}>[UPDATE]</td>
                     <td><a href=purchaseOrder.php?page=24?&poNo={$records['poNo']}>[DELETE]</td>
                   </tr>";
                }
                echo "</table>";
$query = "SELECT *  FROM po
         wHERE (date = str_to_date({$searchString},'%m-%d-%Y') || date like str_to_date ({$searchstring},'%m-%d-%Y)) ";

what if you type something wrong by mistake?
shouldn't you use the form <input type="date"> field? that way you can select the date

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.