Jump to content

Recommended Posts

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

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.