Mi ero dimenticato di postare il codice PHP modificato
Codice PHP:
<?php
function safe_set(&$var_true,$var_false="")
{
if (isset ($var_true))
{ return true; }
else
{
$var_true = $var_false;
return false;
}
}
define ("DB_HOST", "localhost:3307");
define ("DB_USER", "root");
define ("DB_PASSWORD", "root");
define ("DB_DATABASE", "db");
define ("DB_TABLE", "tabella_prova");
define ("CSV_FILENAME", "excelFname.csv");
define ("CSV_FIELD_SEPARATOR", ";");
define ("CSV_ROW_SEPARATOR", "\r\n");
mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error());
mysql_select_db (DB_DATABASE) or die (mysql_error());
... come posso gestire il recupero di due text box?? e come sarà l'HTML della pagina???
if(isset($HTTP_GET_VARS['TextBox']) || isset($HTTP_POST_VARS['TextBox']) )
{
$TextBox = ( isset($HTTP_POST_VARS['TextBox']) )
? htmlspecialchars($HTTP_POST_VARS['TextBox'])
: htmlspecialchars($HTTP_GET_VARS['TextBox']);
}
else
{
$TextBox = 'NULL';
}
.... come posso modificare la select con i due campi recuperati dall'HTML???
$rs = mysql_query ("SELECT * FROM " . DB_TABLE) or die (mysql_error());
$fields_num = mysql_num_fields ($rs);
$field_names = array ();
$cvs = "";
for ($i = 0; $i < $fields_num; $i++)
{
$field_names[] = mysql_field_name ($rs, $i);
if (mysql_field_name ($rs,$i) != "ID")
{ $cvs .= mysql_field_name($rs,$i) . CSV_FIELD_SEPARATOR; }
else
{ $cvs .= "Index" . CSV_FIELD_SEPARATOR; }
}
$cvs .= CSV_ROW_SEPARATOR;
while ($row = mysql_fetch_assoc ($rs))
{
foreach ($field_names as $field_name)
{
safe_set ($row[$field_name], "");
$cvs .= '"' . $row[$field_name] . '"' . CSV_FIELD_SEPARATOR;
}
$cvs .= CSV_ROW_SEPARATOR;
}
header ("Content-type: application/vnd.ms-excel;");
header ("Accept-Ranges: bytes");
header ("Content-Disposition: attachment; filename=".CSV_FILENAME.";");
print ($cvs);
?>