-3

i am working with quarter reports which i can select the quarter that i want to display. if i select 2nd quarter then it will display. the problem is, i want my report to be specific. for example. i have a dropdown which you can select a year. after that, if i select 2011, after i select it then now i can choose the 1st,2nd,3rd or 4th quarter of 2011.. how am i supposed to do that ? here's my code.

<html> 

    Select Year:    <select name="sortyear" id="sortyear">
                                            <option value="2010">2010</option>
                    <option value="2011">2011</option>
                    <option value="2012">2012</option>
                    <option value="2013">2013</option>
                </select>
    <input type = "submit" name = "submit" value = "Select">
</form>
Select year:
<select name="quarter" id="quarter">
<option value="1">1st Quarter</option>
<option value="2">2nd Quarter</option>
<option value="3">3rd Quarter</option>
<option value="4">4th Quarter</option>

</select>
    <input type="submit" name="submit" value="Go">

            <?          

            if($_POST)
            {

$result=mysql_query("SELECT enrollee_info.*, payments.*  FROM enrollee_info INNER JOIN payments ON payments.enrollee_id = enrollee_info.e_id  WHERE    payments.payment_status='Paid'  AND QUARTER(payments.entrydate)='".$quarter."'"); 

             ?>

</form>
user2004096
  • 27
  • 1
  • 2
  • 7
  • Have you had a look at the [MySQL documentation](https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_quarter) for the use of `QUARTER`? – Havelock Mar 09 '13 at 13:25
  • 1
    What have you tried so far? This is not really a question. It is a "look at my code and tell me what to do" comment. Please be more specific, and only show us the code that is relevant to the problem. – Sverri M. Olsen Mar 09 '13 at 13:28
  • how am i to do that , like i select the 1st quarter of 2011 or 2012 something like that – user2004096 Mar 09 '13 at 13:44
  • [Please, don't use mysql_* functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) in new code. They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://uk.php.net/manual/en/function.mysql-connect.php)? Learn about [_prepared statements_](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which. – TNK Mar 09 '13 at 14:13
  • do you know what is the working function for it ? . – user2004096 Mar 09 '13 at 14:39
  • Is this your real code? if so, there are few things that you need to follow. First thing is how to use HTML in a page. Your if condition also have syntax error. And also don't use [php short open tag](http://www.php.net/manual/en/ini.core.php#ini.short-open-tag). It will not support since PHP 5.4 and onward. – TNK Mar 09 '13 at 14:54
  • im working with php short open tag , just edit myphi.ini and that's it – user2004096 Mar 10 '13 at 02:41

1 Answers1

0

For a start this bit of HTML is incorrect (cannot have forms within forms):

                <form action="" id="userLocation" method="post">    
    <form name="sample" method="POST">
        <form method="post" id="category" name="category"> 
        Select Year:    <select name="sortyear" id="sortyear">
                                                <option value="2010">2010</option>
                        <option value="2011">2011</option>
                        <option value="2012">2012</option>
                        <option value="2013">2013</option>
                    </select>
        <input type = "submit" name = "submit" value = "Select">
    </form>
    Select year:
    <select name="quarter" id="quarter">
    <option value="1">1st Quarter</option>
    <option value="2">2nd Quarter</option>
    <option value="3">3rd Quarter</option>
    <option value="4">4th Quarter</option>

    </select>
        <input type="submit" name="submit" value="Go">

You should just have something like the following:

<form action="some URL" method="POST">
    Select Year:    <select name="sortyear" id="sortyear">
                                            <option value="2010">2010</option>
                    <option value="2011">2011</option>
                    <option value="2012">2012</option>
                    <option value="2013">2013</option>
                </select>

Select Quater:
<select name="quarter" id="quarter">
<option value="1">1st Quarter</option>
<option value="2">2nd Quarter</option>
<option value="3">3rd Quarter</option>
<option value="4">4th Quarter</option>

</select>
    <input type="submit" name="submit" value="Go">

</form>
Ed Heal
  • 59,252
  • 17
  • 87
  • 127