theBrent Posted September 2, 2007 Share Posted September 2, 2007 hi guys i'm new here.. and i need help i have a module that sorts all reports by date but it doesn't work i'm not getting any errors.. i'm guessing its my query but i'm not that good in guessing. basically all i want to do is display data depending on what the client is asking.. for example if a client would choose form the dropdown list to display reports in march all reports in march should appear but it doesnt.. here is my code: <?php $month = (isset($_POST['month'])); $year = (isset($_POST['year'])); $totalsale = 0; $totalqty = 0; if(isset($month) && $month != ' '){ $sql = "SELECT * FROM tbl_order od, tbl_order_item o, tbl_product pd WHERE od.od_id = o.od_id and o.pd_id = pd.pd_id AND od.od_status = 'Paid' AND MONTH(od_date) = '$month' AND YEAR(od_date) = '$year'"; }else{ $sql = "SELECT * FROM tbl_order od, tbl_order_item o, tbl_product pd WHERE od.od_id = o.od_id and o.pd_id = pd.pd_id AND od.od_status = 'Paid'"; } $result = dbQuery($sql); ?> <form action="index.php?view=sales" method="post"> <table width="80%" cellpadding="5" cellspacing="0" border="1" sytle="font-family:arial;color:purple;font-size:12px" align="center"> <tr> <td style="font-size:20px;color:purple;font-family:arial" colspan="7" align="center">SALES REPORT</td> </tr> <tr> <td colspan="7"> Month and Year required<br><br> <select name="month"> <option>--selected--</option> <option value="01">January</option> <option value="02">Febuary</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="year"> <option>--selected--</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <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> </select> <input type="submit" value="sort"> </td> </tr> <tr> <td>Order Date</td> <td>Order ID</td> <td>First Name</td> <td>Last Name</td> <td>Order Quantity</td> <td>Price</td> <td>Total Amount(Tax included)</td> </tr> <?php while ($row = dbFetchAssoc($result)){ extract($row); $tax = $pd_price * 0.12; $total = $od_qty * $pd_price + $tax; $totalsale += $total; $totalqty += $od_qty; ?> <tr> <td><?php echo $od_date;?></td> <td align="center"><?php echo $od_id;?></td> <td><?php echo $od_payment_first_name;?></td> <td><?php echo $od_payment_last_name;?></td> <td align="center"><?php echo $od_qty;?></td> <td><?php echo displayAmount($pd_price);?></td> <td align="center"><?php echo displayAmount($total);?></td> </tr> <?php } ?> <tr> <td colspan="7"> </td> </tr> <tr> <td colspan="7"> <?php echo "Total Items Sold:"." ".$totalqty;?> </td> </tr> <tr> <td colspan="7"> <?php echo "Total Sales:"." ".displayAmount($totalsale);?> </td> </tr> </table> </form> could it be my query is incomplete? i'am really not that good in php so please help! thank you! Link to comment https://forums.phpfreaks.com/topic/67657-how-do-i-sort-by-month-from-database/ Share on other sites More sharing options...
Barand Posted September 2, 2007 Share Posted September 2, 2007 There is no db connection code shown. after $result = dbQuery($sql); try if (!$result) echo dbError(); // or whatever your error message function is Link to comment https://forums.phpfreaks.com/topic/67657-how-do-i-sort-by-month-from-database/#findComment-339942 Share on other sites More sharing options...
tibberous Posted September 2, 2007 Share Posted September 2, 2007 Problem: $month = (isset($_POST['month'])); $year = (isset($_POST['year'])); You setting them to isset, which is setting them to false or true. Link to comment https://forums.phpfreaks.com/topic/67657-how-do-i-sort-by-month-from-database/#findComment-339946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.