ok,
Let's go here..!
------------------------------- generate_report.php ------------------
<?
// 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);
}
?>
<fieldset><legend>Generate Report</legend>
<form action="generate_report.php" method="post">
<CENTER>
<TABLE BORDER="1" cellpadding="5" cellspacing="5">
<TR>
<TD rowspan="2" valign="bottom"><strong>Select
Group(s)</strong></TD>
<TD colspan="2"><strong>Select Columns</strong></TD>
</TR>
<TR>
<TD><strong>Category One</strong></TD>
<TD><strong>Category Two</strong></TD>
</TR>
<TR>
<TD align="left" valign="top">
<input name="sel_group[]" type="checkbox" value="1">Group A<BR>
<input name="sel_group[]" type="checkbox" value="2">Group B<BR>
<input name="sel_group[]" type="checkbox" value="3">Group C<BR>
<input name="sel_group[]" type="checkbox" value="4">Group D<BR>
</TD>
<TD align="left">
<input name="sel_cols[]" type="checkbox" value="Column
A">Column
A<BR>
<input name="sel_cols[]" type="checkbox" value="Column
B">Column
B<BR>
<input name="sel_cols[]" type="checkbox" value="Column
C">Column
C<BR>
<input name="sel_cols[]" type="checkbox" value="Column
D">Column
D<BR>
<input name="sel_cols[]" type="checkbox" value="Column
E">Column
E<BR>
<input name="sel_cols[]" type="checkbox" value="Column
F">Column
F<BR>
</TD>
<TD align="left">
<input name="sel_cols[]" type="checkbox" value="Column
G">Column
G<BR>
<input name="sel_cols[]" type="checkbox" value="Column
H">Column
H<BR>
<input name="sel_cols[]" type="checkbox" value="Column
I">Column
I<BR>
<input name="sel_cols[]" type="checkbox" value="Column
J">Column
J<BR>
<input name="sel_cols[]" type="checkbox" value="Column
K">Column
K<BR>
<input name="sel_cols[]" type="checkbox" value="Column
L">Column
L<BR>
</TD>
</TR>
</TABLE>
</CENTER>
<input name="submit" type="submit" value="Generate">
</form>
</fieldset>
-------------------------- end generate_report.php ------------------
Good Luck Buddy!!
Regards,
Luis Morales
On Tue, 2006-02-21 at 23:06 -0500, Jeff Broomall wrote:
> I thank those who promptly responded to my first inquiry on the list.
>
> This second request is, I assume, a tad more challanging.
>
> I need a "Generate Report" function that'll allow the user to select one or
> more "groups" and what columns he would like to view.
>
> For instance,
>
> <fieldset><legend>Generate Report</legend>
>
> <form action="generate_report.php" method="post">
> <CENTER>
> <TABLE BORDER="1" cellpadding="5" cellspacing="5">
> <TR>
> <TD rowspan="2" valign="bottom"><strong>Select Group(s)</strong></TD>
> <TD colspan="2"><strong>Select Columns</strong></TD>
> </TR>
> <TR>
> <TD><strong>Category One</strong></TD>
> <TD><strong>Category Two</strong></TD>
> </TR>
>
> <TR>
> <TD align="left" valign="top">
> <input name="sel_group[]" type="checkbox" value="1">Group A<BR>
> <input name="sel_group[]" type="checkbox" value="2">Group B<BR>
> <input name="sel_group[]" type="checkbox" value="3">Group C<BR>
> <input name="sel_group[]" type="checkbox" value="4">Group D<BR>
> </TD>
>
> <TD align="left">
> <input name="sel_cols[]" type="checkbox" value="Column A">Column
> A<BR>
> <input name="sel_cols[]" type="checkbox" value="Column B">Column
> B<BR>
> <input name="sel_cols[]" type="checkbox" value="Column C">Column
> C<BR>
> <input name="sel_cols[]" type="checkbox" value="Column D">Column
> D<BR>
> <input name="sel_cols[]" type="checkbox" value="Column E">Column
> E<BR>
> <input name="sel_cols[]" type="checkbox" value="Column F">Column
> F<BR>
> </TD>
> <TD align="left">
> <input name="sel_cols[]" type="checkbox" value="Column G">Column
> G<BR>
> <input name="sel_cols[]" type="checkbox" value="Column H">Column
> H<BR>
> <input name="sel_cols[]" type="checkbox" value="Column I">Column
> I<BR>
> <input name="sel_cols[]" type="checkbox" value="Column J">Column
> J<BR>
> <input name="sel_cols[]" type="checkbox" value="Column K">Column
> K<BR>
> <input name="sel_cols[]" type="checkbox" value="Column L">Column
> L<BR>
> </TD>
> </TR>
>
> </TABLE>
> </CENTER>
>
> <input name="submit" type="button" value="Generate">
>
> </form>
>
> </fieldset>
>
> Let's say the user wants to view Group A and Group B AND view content from
> the Coulmn A, Column B, Column D, and Column K.
>
> So a checkmark would be placed within each box and the "Generate Report"
> button would be "hit" to generate a report with titles situated
> horizontally.
>
> I'm assuming I'll need to create an array for both "sel_group" and
> "sel_cols" and then, I believe it's "implode" them into string values??? Am
> I thinking correctly???
>
> I know this query won't work...but this is the direction I'm headed...
>
> $query = "SELECT $sel_cols FROM tasks WHERE groups_id=$sel_groups";
>
> IOW, the columns from the sel_cols array would go there, and the group
> or groups would go after the WHERE statement.
>
> Then I guess I would have to figure out the code for the echo.
>
> Am I at least in the ballpark???
>
> Thank you and good night.
>
> Jeff
>
--
---------------------------------------------------------------------------------
Luis Morales
Consultor de Tecnologia
Cel: +(58)416-4242091
---------------------------------------------------------------------------------
"Empieza por hacer lo necesario, luego lo que es posible... y de pronto
estarĂ¡s haciendo lo imposible"
---------------------------------------------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php