Jump to content

multiple search -php&mysql-


wanted

Recommended Posts

I tried my best but it still cant solve. I hope u guys can help me. Here i've problem with how to do search in year & month using php & mysql. My problem is i'dont know how to take date ("d/m/Y") m(month) & Y(year) from my database. Format date ("d/m/Y"). Main idea is to display year first followed by month.It have 2 selection list, that is year(2008) & month(Jan-Dec). But i've done year first & still not getting anything.. this is my code

 

<?php

mysql_connect ("","","")or die (mysql_error());
mysql_select_db ("") or die (mysql_error());

$receivedDate = date ("d/m/Y");
$split = sprintf('%02d%02d%04d', $d, $m, $Y);
$d = $components[1];
$m = $components[2];
$Y = $components[3];

if ($_POST['selectOrder'] = "2008") {

$Y =$_POST['selectOrder'];
$sql = sprintf ("SELECT * FROM tbl_order WHERE [b]year[/b](receivedDate =) %d", $Y);
echo ($sql);

{
}

}

?>

<form action="" method="post" name="form1" id="form1">
<p align="center">
          <select name="selectOrder" id="selectOrder">
            <option selected="selected">- Year -</option>
            <option value="2008">2008</option>
   </select><br><br>
</p>
</form>

 

Link to comment
Share on other sites

One solution is to store dates as a "timestamp" and then translate them through php before showing them on-screen to users.  Doing so allows you the greatest flexibility and allows you to store day, month, year, hour, minute, and second all at once.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.