<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
</head>
<body>
<?php
//establish oyur database connection here
// assuming your connection is called $db
// using PDO because it is best to use
$validtypes=array('title','author','channel');
if(isset($_POST['reptype']))
{
$rtype=stripslashes($_POST['reptype']);
if(in_array($rtype,$validtypes))
{
$sql_str="select ?, sum(invoice_amount) as total_amount from tablename where date_sub(curdate(), INTERVAL 1 YEAR) group by ?";
$result=$db->prepare($sql_str));
$result->execute($rtpe, $rtype);
while($row=$result->fetch(PDO::FETCH_ASSOC))
{
// echo data here
}
}
else
{
// put some error code here
}
echo "<br><a href=thispage.php>Run another report</a></br>";
}
else
{
?>
<form name="reportform" method=POST" action="thispage.php">
Select report type:
<select name="reptype" onChange="this.form.submit();">
<option "title">By Title</option>
<option "author">By Author</option>
<option "channel">By Channel</option>
</select>
</form>
<?php
}
?>
</body>
</html>
__________________
All cookies cleared!
|