wmguk Posted March 15, 2008 Share Posted March 15, 2008 Hey guys, I need to do a search page, I am looking for a page with 3 drop downs. 1) Display all orders from account [All, account1, account2 etc etc] 2) During the months of [Jan, Feb, Mar etc] 3) During the year of [2004, 2005, 2006] but I want the drop down value to only show the details already in the database, (for the account name) any thoughts how I should do this, I was shown a query using MySQL yesterday, rather than PHP, which is much quicker however what way would you do it, and any thoughts on any code would be great. I have seen self generating drop downs before, but have googled and cannot find anything. Cheers in advance Link to comment https://forums.phpfreaks.com/topic/96273-query-string-help-ideas/ Share on other sites More sharing options...
wmguk Posted March 15, 2008 Author Share Posted March 15, 2008 Hey, ok so i found the distinct !! however now I cant pull out the month or year from the datestamp any thoughts? <? include "../scripts/connection.php"; if (!$conn) { die( 'Could not connect: ' . mysql_error() ); } mysql_select_db($db, $conn); $sql="SELECT DISTINCT (loginid), albumname FROM orders"; $sql2="SELECT DISTINCT *, MONTH(orderdate) AS month FROM orders"; $sql3="SELECT DISTINCT *, YEAR(orderdate) AS year FROM orders"; $result=mysql_query($sql); $result2=mysql_query($sql2); $result3=mysql_query($sql3); //ALBUMS $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["loginid"]; $thing=$row["albumname"]; $options.="<OPTION VALUE=\"$id\">".$thing.'</option>'; } //MONTHS $options2=""; while ($row=mysql_fetch_array($result2)) { $id2=$row["month"]; $thing2=$row["month"]; $options2.="<OPTION VALUE=\"$id2\">".$thing2.'</option>'; } //YEARS $options3=""; while ($row=mysql_fetch_array($result3)) { $id3=$row["year"]; $thing3=$row["year"]; $options3.="<OPTION VALUE=\"$id3\">".$thing3.'</option>'; } ?> <form action="" class="main" name="searchtype"> <SELECT NAME="album" id="album" class="main"> <option value="All Your Albums">All Your Albums <?=$options;?> </SELECT> <br /> <SELECT NAME="month" id="month" class="main"> <OPTION VALUE=0>All Months <?=$options2;?> </SELECT> <br /> <SELECT NAME="year" id="year" class="main"> <OPTION VALUE=0>All Years <?=$options3;?> </SELECT> </FORM> Link to comment https://forums.phpfreaks.com/topic/96273-query-string-help-ideas/#findComment-492834 Share on other sites More sharing options...
wmguk Posted March 15, 2008 Author Share Posted March 15, 2008 ok, fixed that, lol Link to comment https://forums.phpfreaks.com/topic/96273-query-string-help-ideas/#findComment-492949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.