|
Posted by ward on 05/10/06 18:16
Greetings.
I'm really under the gun here and could use some help. I've been
spending too much time racking my brains trying to figure this
function out. I've tried hacking away at other scripts but I think
this one is just a tad more complicated and requires expert advice.
Here is what I want to accomplish:
Provide a webpage that'll allow the user to select records to be
retrieved from:
a. certain groups
b. desired fields.
In other words, I'd like to like the user select Group A, Group B,
and/or Group C AND show Fields A, C, D, F.
As for the process, I see three steps:
1) generate form
2) extract data from arrays to run the query
3) present the report
The file I'm showing below has modified by someone who said I needed
to use PEAR. Well, I don't think it's an option so I was hoping there
would be a non-PEAR solution.
What I get now is the form coming up, but nothing happens when I hit
the "Generate" button. Hmmmm....I would think at least something
would happen to generate an error.
Thoughts/suggestions would be greatly appreciated.
Thanks.
Ward
<?PHP
// Begin the page now.
$page_title = 'Generate Report';
include ('./includes/header.html');
$mdb = new mdb;
$report = false;
// Check if the form has been submitted.
switch ($_REQUEST['submit']){
case "Generate":
// first extract group
$query = "";
if(count($_REQUEST['sel_groups']) > 0){
$wval = array ();
foreach($_REQUEST['sel_groups'] as $k => $v){
$wval[] = "groups_id='{$v}'";
}
//extract the columns
$scols = array ();
if(count($_REQUEST['sel_cols]']) > 0){
foreach($_REQUEST['sel_cols'] as $k => $v){
$scols[] = "{$v}";
}
//building query
$where = join(' AND ', $wval);
$sel_cols = join(',', $scols);
require_once ('includes/mysql_connect.php'); //
Connect to the db.
$query = "SELECT {$sel_cols} FROM tasks WHERE {$where}";
if($db->db_dbArray($DB, $query)){
$report = (count($db->_db[data]) > 0);
}
}
}
break;
default:
}
if($report){
?>
<table height="0%" width="0%" cellpadding="3" cellspacing="1"
align="center" bgcolor="#000000">
<tr bgcolor="#cccccc" align="center">
<? foreach($_REQUEST['sel_groups'] as $k => $v){?>
<td><b><?= $v ?></b></td>
<? } ?>
</tr>
<? for($i=0;$i<count($db->_db[data]);$i++){ ?>
<tr bgcolor="#ffffff" align="center">
<? foreach($_REQUEST['sel_groups'] as $k => $v){?>
<td><?= $db->_db[data][$i][$v] ?></td>
<? } ?>
</tr>
<?}?>
</table>
<?
}
echo '<fieldset><legend>Generate Report</legend>
<form action="generate_report_v11.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">';
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_groups[]\" type=\"checkbox\"
value=\"$id\">$name<BR>\n";
}
echo '
</TD>
<TD align="left" valign="top">
<input name="sel_cols[]" type="checkbox" value="groups_name">
Group Name<BR>
<input name="sel_cols[]" type="checkbox"
value="task_desc">Description of Task<BR>
<input name="sel_cols[]" type="checkbox" value="task_id">Task
No.<BR>
<input name="sel_cols[]" type="checkbox"
value="task_compdate">Estimated Completion Date<BR>
<input name="sel_cols[]" type="checkbox"
value="task_source">Source & References<BR>
<input name="sel_cols[]" type="checkbox" value="task_note">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 & Issues<BR>
<input name="sel_cols[]" type="checkbox"
value="task_smecomments">Notes/Comments<BR>
</TD>
</TR>
</TABLE></CENTER>
<input name="submit" type="submit" value="Generate">
</form>
</fieldset>';
include ('includes/footer.html')
?>
Navigation:
[Reply to this message]
|