UD2006
09-15-2009, 12:38 PM
I have a page on which I can make selections and display the values of those selection (selected checkboxes).
For example, on the page I have checkboxes 1 till 6, and 2, 4, 5 are checked, the records in mysql with the values 1 on fields or checkboxes 2, 4 and 5 should be displayed. If no checkbox is checked no records are being displayed(exported).
This is the code from the export page: (the records are being exported to an excel file, that works, but no records are in that file, when I know a record has a value of 1 from a checked checkbox).
<?php
function exportMysqlToCsv($table,$filename = 'selecties contact database.csv')
{
if (!empty($_GET['nbs_vmb_lid_vmb'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_selfburns'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_profrelatie'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_psychonet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_revalinet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_reintegranet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_juridischehulp'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_nomail'])) ? 1 : 0;
$csv_terminated = "\n";
$csv_separator = ";";
$csv_enclosed = '"';
$csv_escaped = "\\";
$sql_query = "SELECT nbs_vmb_contact_aanhef, nbs_vmb_contact_prechar, nbs_vmb_contact_name, nbs_vmb_contact_tussenv, nbs_vmb_contact_sur, nbs_vmb_address, nbs_vmb_number, nbs_vmb_numberadd, nbs_vmb_zip, nbs_vmb_postbusnr, nbs_vmb_city, nbs_vmb_country, nbs_vmb_emailadres FROM $table where nbs_vmb_group_id = '2' AND nbs_vmb_lid_vmb = $nbs_vmb_lid_vmb";
// Gets the data from the database
$result = mysql_query($sql_query);
$fields_cnt = mysql_num_fields($result);
?>
This is the code from the selection page:
<form id="form_ins_contact" name="form_ins_contact" method="get" action="test.php">
<table width="680" height="350" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[36]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_lid_vmb" type="checkbox" value="1" <?php if ($nbs_vmb_lid_vmb == "1") echo "checked"; ?> /></td>
<td class="td_no_border2"></td>
<td class="td_no_border2"></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[37]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_selfburns" type="checkbox" <?php if ($nbs_vmb_selfburns == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[29]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_zip" type="text" id="nbs_vmb_zip" size="15" /></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[40]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_profrelatie" type="checkbox" <?php if ($nbs_vmb_profrelatie == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[35]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_contact_day" type="text" id="nbs_vmb_contact_day" maxlength="2" size="1" />
<input name="nbs_vmb_contact_month" type="text" id="nbs_vmb_contact_month" maxlength="2" size="1" />
<input name="nbs_vmb_contact_year" type="text" id="nbs_vmb_contact_year" maxlength="4" size="3" /></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[42]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_revalinet" type="checkbox" <?php if ($nbs_vmb_revalinet == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[38]; ?></strong></td>
<td class="td_no_border" width="194"><input name="nbs_vmb_year" type="text" id="nbs_vmb_year" size="15" /></td>
</tr>
<tr>
<td align="right"><strong><?php echo $tcm_label[44]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_juridischehulp" type="checkbox" <?php if ($nbs_vmb_juridischehulp == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[41]; ?></strong></td>
<td class="td_no_border" width="194"><input value="1" name="nbs_vmb_psychonet" type="checkbox" <?php if ($nbs_vmb_psychonet == "1") echo "checked"; ?> /></td>
</tr>
<tr>
<td align="right"><strong><?php echo $tcm_label[45]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_nomail" type="checkbox" <?php if ($nbs_vmb_nomail == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[43]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_reintegranet" type="checkbox" <?php if ($nbs_vmb_reintegranet == "1") echo "checked"; ?> /></td>
</tr>
<input type="submit" class="buttons" value="Export Selecties" />
</form>
Hope someone can help me with this.
For example, on the page I have checkboxes 1 till 6, and 2, 4, 5 are checked, the records in mysql with the values 1 on fields or checkboxes 2, 4 and 5 should be displayed. If no checkbox is checked no records are being displayed(exported).
This is the code from the export page: (the records are being exported to an excel file, that works, but no records are in that file, when I know a record has a value of 1 from a checked checkbox).
<?php
function exportMysqlToCsv($table,$filename = 'selecties contact database.csv')
{
if (!empty($_GET['nbs_vmb_lid_vmb'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_selfburns'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_profrelatie'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_psychonet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_revalinet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_reintegranet'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_juridischehulp'])) ? 1 : 0;
if (!empty($_GET['nbs_vmb_nomail'])) ? 1 : 0;
$csv_terminated = "\n";
$csv_separator = ";";
$csv_enclosed = '"';
$csv_escaped = "\\";
$sql_query = "SELECT nbs_vmb_contact_aanhef, nbs_vmb_contact_prechar, nbs_vmb_contact_name, nbs_vmb_contact_tussenv, nbs_vmb_contact_sur, nbs_vmb_address, nbs_vmb_number, nbs_vmb_numberadd, nbs_vmb_zip, nbs_vmb_postbusnr, nbs_vmb_city, nbs_vmb_country, nbs_vmb_emailadres FROM $table where nbs_vmb_group_id = '2' AND nbs_vmb_lid_vmb = $nbs_vmb_lid_vmb";
// Gets the data from the database
$result = mysql_query($sql_query);
$fields_cnt = mysql_num_fields($result);
?>
This is the code from the selection page:
<form id="form_ins_contact" name="form_ins_contact" method="get" action="test.php">
<table width="680" height="350" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[36]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_lid_vmb" type="checkbox" value="1" <?php if ($nbs_vmb_lid_vmb == "1") echo "checked"; ?> /></td>
<td class="td_no_border2"></td>
<td class="td_no_border2"></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[37]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_selfburns" type="checkbox" <?php if ($nbs_vmb_selfburns == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[29]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_zip" type="text" id="nbs_vmb_zip" size="15" /></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[40]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_profrelatie" type="checkbox" <?php if ($nbs_vmb_profrelatie == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[35]; ?></strong></td>
<td class="td_no_border"><input name="nbs_vmb_contact_day" type="text" id="nbs_vmb_contact_day" maxlength="2" size="1" />
<input name="nbs_vmb_contact_month" type="text" id="nbs_vmb_contact_month" maxlength="2" size="1" />
<input name="nbs_vmb_contact_year" type="text" id="nbs_vmb_contact_year" maxlength="4" size="3" /></td>
</tr>
<tr>
<td width="160" align="right"><strong><?php echo $tcm_label[42]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_revalinet" type="checkbox" <?php if ($nbs_vmb_revalinet == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[38]; ?></strong></td>
<td class="td_no_border" width="194"><input name="nbs_vmb_year" type="text" id="nbs_vmb_year" size="15" /></td>
</tr>
<tr>
<td align="right"><strong><?php echo $tcm_label[44]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_juridischehulp" type="checkbox" <?php if ($nbs_vmb_juridischehulp == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[41]; ?></strong></td>
<td class="td_no_border" width="194"><input value="1" name="nbs_vmb_psychonet" type="checkbox" <?php if ($nbs_vmb_psychonet == "1") echo "checked"; ?> /></td>
</tr>
<tr>
<td align="right"><strong><?php echo $tcm_label[45]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_nomail" type="checkbox" <?php if ($nbs_vmb_nomail == "1") echo "checked"; ?> /></td>
<td align="right"><strong><?php echo $tcm_label[43]; ?></strong></td>
<td class="td_no_border"><input value="1" name="nbs_vmb_reintegranet" type="checkbox" <?php if ($nbs_vmb_reintegranet == "1") echo "checked"; ?> /></td>
</tr>
<input type="submit" class="buttons" value="Export Selecties" />
</form>
Hope someone can help me with this.