i have an event form, which have some fields..and when the form is filled correct..i store the data in mysql table, and a email sent to registrant..
i want in my admin side (manager) only for admins, show the registrered data...
how can i do that..?
how can i make a html/php file only viewable inside manager folder...
what i mean is if i f.ex put a file inside the manager folder..how can i make it not viewable for public..?
A module is only available inside the Manager to logged in Manager Users.
It can be used to display, edit, delete etc. data from a database.
the modules are working great.
but how can i f.ex export to excel file or csv file...
I just use something like this near the top of the module:
// Export to CSV
if(isset($_GET['exportAll'])){
$output = '';
$query = "SHOW COLUMNS FROM $tbl";
$result = $modx->dbQuery($query);
$columns = $modx->recordCount($result);
$fields=array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
array_push($fields,$row["Field"]);
}
// Add the name of all fields
for ($i = 0; $i < $columns; $i++) {
$output .= '"'.$fields[$i].'",';
}
$output .="\n";
$query = "SELECT * FROM $tbl ORDER BY started DESC";
$result = $modx->dbQuery($query);
// Add all values in the table
while ($l = mysql_fetch_array($result)) {
for ($i = 0; $i < $columns; $i++) {
$output .='"'.$l["$i"].'",';
}
$output .="\n";
}
// Output to browser with appropriate mime type (some options below)
header("Content-type: text/x-csv");
//header("Content-type: text/csv");
//header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=yournamehere-".date("Y-m-d").".csv");
echo $output;
exit;
}
Not sure where I came across that code originally, but it works fine for me.