Gideon_1 15 Junior Poster

Can you send me the fields you want use in creating this form

Gideon_1 15 Junior Poster

Really, I thought here is a forum which help solve problems but not generating codes for people. But by the way you can show us what you have done, so maybe we can continue it for you.

Gideon_1 15 Junior Poster

Hmm, this really depends on you.

Or, try to figure out some solutions to problems in every day life like companies doing stuffs like writing receipts by hand. Create a template for them.

Gideon_1 15 Junior Poster

Yah, your dates can also be problem. use

    $date1 = "{$year}-{$month}-{$startday}";
    $date2 = "{$year}-{$month}-{$endday}";

so try the sql

SELECT * FROM presence WHERE user_id = {$id} AND p_date BETWEEN {$date1} AND {$date2} ORDER BY p_date

Then echo out mysqli_num_rows

Gideon_1 15 Junior Poster

try echoing out the mysqli_num_rows($query_get)

Gideon_1 15 Junior Poster

You have made many mistakes of which include
1. Setting Form action to POST but using GET in PHP
2. Did not initialize mysqli connection
3. Were not sorting output by any column but instead you used a function.

Try these codes and make changes to it so it matches with your credentials

<form name="form1" method="POST" action="status_rep.php">
    <label>
        <p>Select Month</p>
        <p class="info">
            <select name="month">
                <option value="1">January</option>
                <option value="2">February</option>
                <option value="3">March</option>
                <option value="4">April</option>
                <option value="5">May</option>
                <option value="6">June</option>
                <option value="7">July</option>
                <option value="8">August</option>
                <option value="9">September</option>
                <option value="10">October</option>
                <option value="11">November</option>
                <option value="12">December</option>
            </select>
        </p>
    </label>

    <div class="clear"></div>

    <label>
        <p>Select Year</p>
        <p class="info">
            <select name="year">
                <option value="2014">2014</option>
                <option value="2015">2015</option>
                <option value="2016">2016</option>
                <option value="2017">2017</option>
                <option value="2018">2018</option>
                <option value="2019">2019</option>
                <option value="2020">2020</option>
                <option value="2021">2021</option>
                <option value="2022">2022</option>
                <option value="2023">2023</option>
                <option value="2024">2024</option>
                <option value="2025">2025</option>
                <option value="2026">2026</option>
            </select>
        </p>
    </label>

    <div class="input" style="text-align:center;">
        <input type="submit" value="View" class="btn1" name="show" />
    </div>
</form>

<div class="clear"></div>

<?php
    if(isset($_POST['month']) && isset($_POST['year'])) {
        $month = intval($_POST["month"]);
        $year  = intval($_POST["year"]);
    } else {
        $month = date("m");
        $year  = date("Y"); 
    }


    echo "<script language = 'javascript'>
             form1.month.options[",$month-1,"].selected = true;
             form1.year.options[",$year-2014,"].selected = true;
         </script>";


    $startday = 1;

    //endday for months with 31 days
    if($month==1 || $month==3 || $month==5 || $month==7 || $month==8 || $month==10 || $month==12) {
        $endday = 31;
    }

    //endday for months with 30 days
    if($month==4 || $month==6 || $month==9 || $month==11) {
        $endday = 30;
    }

    //endday for february
    if($month==2) {
        if($year%4==0) {
            $endday = 29;
        }else {
            $endday = 28;
        }
    }
    $date1 = $year . "-" . $month . "-" . …
Gideon_1 15 Junior Poster

Your are still using ORDER BY DATE instead of p_date. Also you can save you fetch_assoc to an array and use fetch assoc to ouput the data which will be relevantly fast than echoing every thing bit by bit when dealing with huge amount of data.

Gideon_1 15 Junior Poster

I don't know whether your codes are just for training purposes but for production purposes declare the state of your methods, be it, public, private or protected

Gideon_1 15 Junior Poster

In addition, try to use mysqli or PDO since mysql extension has been deprecated since PHP 5.0.

Gideon_1 15 Junior Poster

I think provided your query is correct, use a while loop to output the rows like

$query = //this is your SQL statement;

while ($row = $query->fetch_object()) {
    echo $row->id, '<br>';
    echo $row->the name of your column you selected;
}
Gideon_1 15 Junior Poster

You can also predefine the doctype and head tags in the current page and the load the contents of the inc.php files

Gideon_1 15 Junior Poster

can i say, have you set the session.