473,379 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Stuck & Need Help with "Generate Report"

Greetings.

Ok, I admit it, I bit off a bit more than I can chew.

I need to complete this "Generate Report" page for my employer and I'm
a little over my head. I could use some additional assistance. I say
additional because I've already had help which is greatly appreciated.
I do try to take the time and understand the provided script in hopes
on not having to trouble others on those. But here it goes...

I need to allow the user to generate a report and thus have created a
file called generate_report.php.

I have a header.html and footer.html file so I'm just trying to fill
in the middle.

What I want to do is create a single file to display and process the
form.

What I have is a set of records from three different groups. I want
to allow the user to select what group's records he would like to
extract data from and what columns he wants displayed. So, I have
basically two columns in the form: 1) what group(s) and 2) what
column(s).

Now, the "what group(s)" column has a script to extract the list of
groups from a table of the same name and display it as a checkbox
list.

The other column, "select columns" is a simple checkbox listing.

So, ideally, when the page is brought up for the first time, it'll
recognize the "submit" button hasn't been hit and will display the
form. Once the user selects group(s) and column(s) and hits submit
(or in this case "Generate), the output would be a page with the
columns aligned horizontally and data underneath each header (just
like a spredsheet).

So, this is what I think I need:

1) A script that will process the sel_groups and sel_cols arrays
(which has been provided but not tested); and

2) an echo statement that'll produce the desired output.

I'm going to fart around with it some more but would really appreciate
some help.

Oh, one question that just popped up (and I'll reseach it)...

can I have this page split PHP | HTML |PHP when using the "if
submitted" statement? Seems like I would need to have just a single
php file so that if sumbitted, here is the query and output BUT if not
submitted, here is the form. Hmmm...I need to think that one through
a bit more.

Thanks.

Ward.

<?PHP

// Begin the page now.
$page_title = 'Generate Report';
include ('./includes/header.html');
//require_once ('includes/mysql_connect.php'); // Connect to
the db.

// Check if the form has been submitted.
if (isset($_POST['submitted'])) {

require_once ('includes/mysql_connect.php'); // Connect to the
db.

// this script only build query
switch ($_REQUEST['submit']){
case "Generate":

// first extract group
$query = "";
if(count($_REQUEST['sel_group']) > 0){
$wval = array ();
foreach($_REQUEST['sel_group'] as $k => $v){
$wval[] = "groups_id='{$v}'";
}

//extract the columns
$scols = array ();
if(count($_REQUEST['sel_cols]']) > 0){
foreach($_REQUEST['sel_group'] as $k => $v){
$scols[] = "{$v}";
}

//building query
$where = join(' AND ', $wval);
$sel_cols = join(',', $scols);
$query = "SELECT {$sel_cols} FROM tasks WHERE
{$where}";
}

}

//if $query is empty you can catch this case as an error
because there is not any group or selected columns

break;

default:

//reset your form
unset($_REQUEST);
}
//} End of submit conditional.
//Output Form
// Always show the form.

} else { // Not a valid user ID.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in
error.</p><p><br /><br /></p>';
}

mysql_close(); // Close the database connection.

// End of links section.

?>

<!--Create the form.-->
<fieldset><legend>Generate Report</legend>

<form action="handle_generate_report.php"
method="post">

<CENTER>
<TABLE BORDER="1" cellpadding="5"
cellspacing="5">
<TR>
<TD rowspan="2"
valign="bottom"><strong>Select ICAO Group(s)</strong></TD>
<TD
colspan="2"><strong>Select Columns</strong></TD>
</TR>
<TR>
<TD><strong>ICAO Work
Programme</strong></TD><TD><strong>SME Input</strong></TD>
</TR>
<TR>
<TD align="left"
valign="top">
<?php
require_once
('includes/mysql_connect.php'); // Connect to the db.
$query = "SELECT *
FROM groups ORDER BY groups_id ASC";
$result = @mysql_query
($query);

while($rows =
mysql_fetch_array($result))
{
$id =
$rows['groups_id'] ;
$name =
$rows['groups_name'];

echo "<input
name=\"sel_group[]\" type=\"checkbox\" value=\"$id\">$name<BR>";
}
?>
</TD>
<TD align="left" valign="top">
<input name="sel_cols"
type="checkbox" value="groups_name">ICAO Group Name<BR>
<input name="sel_cols"
type="checkbox" value="task_icaodesc">ICAO Description of Task<BR>
<input name="sel_cols"
type="checkbox" value="icaotask_id">ANC Task No.<BR>
<input name="sel_cols"
type="checkbox" value="task_compdate">Estimated Completion Date<BR>
<input name="sel_cols"
type="checkbox" value="task_icaosource">Source &amp; References<BR>
<input name="sel_cols"
type="checkbox" value="task_icaonote">ICAO Note on Progress<BR>
</TD>
<TD align="left" valign="top">
<input name="sel_cols"
type="checkbox" value="task_usposition">U.S. Position<BR>
<input name="sel_cols"
type="checkbox" value="task_exp_outcome">Expected Outcome<BR>
<input name="sel_cols"
type="checkbox" value="task_outcome">Outcome<BR>
<input name="sel_cols"
type="checkbox" value="task_usaction">U.S. Action<BR>
<input name="sel_cols"
type="checkbox" value="task_probs_issues">Problems &amp; Issues<BR>
<input name="sel_cols"
type="checkbox" value="task_smecomments">Notes/Comments<BR>
</TD>
</TR>

</TABLE></CENTER>

<input name="submit"
type="button" value="Generate">

</form>

</fieldset>
<!-- End of Content -->
</td>
</tr>

</table>
<?php
include ('includes/footer.html')
?>
Feb 25 '06 #1
0 2223

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sztonix | last post by:
Hi all, I encountered a crystal report deployment problem. I make reports with Crystal Report for Visual Studio .NET 2003. It works fine in the development machine. And then make setup...
0
by: Will | last post by:
Hi all, The documentation for NGEN states "If Ngen.exe encounters any methods in an assembly that it cannot generate, it excludes them from the native image. When the runtime executes this...
1
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
7
by: Ellen Manning | last post by:
I've got an A2K report showing students and their costs. Student info is in the main report and costs are in a subreport for each student. The user inputs the program desired then only those...
1
by: laddie1997 | last post by:
When I try to create a report in Access 2003, the error message "the wizard is unable to create your report" comes up. My printer is a network printer and no local printer is attached. I can get...
2
by: Delali Dzirasa | last post by:
I am a newbie and am creating my first asp.net in crystal reports. I have created the report (.rpt file) and have dropped the CrystalReportViewer on the web form. From the databinding...
1
by: Dentharg | last post by:
Hi! How can I rename this tab in Crystal Report Viewer from "Main Report" to something else? Thanks!
9
by: Anneybo | last post by:
Alright, I give up! I'm asking the experts. I have created a database that calculates PTO for employees. I need to be able to cache the report by user entered dates and specific employee names. I...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.