Export to excel
I am trying to get my results in an excel sheet, but after days of trying it won't work. Maybe somebody will help me with it.
Thanks
Marj Wouterse
<?php require_once('../../Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname1_rs_select_leden = "-1";
if (isset($_POST['overleden'])) {
$colname1_rs_select_leden = (get_magic_quotes_gpc()) ? $_POST['overleden'] : addslashes($_POST['overleden']);
}
$colname2_rs_select_leden = "-1";
if (isset($_POST['opgezegd'])) {
$colname2_rs_select_leden = (get_magic_quotes_gpc()) ? $_POST['opgezegd'] : addslashes($_POST['opgezegd']);
}
$colname3_rs_select_leden = "-1";
if (isset($_POST['betalend_lid'])) {
$colname3_rs_select_leden = (get_magic_quotes_gpc()) ? $_POST['betalend_lid'] : addslashes($_POST['betalend_lid']);
}
mysql_select_db($database_localhost, $localhost);
$query_rs_select_leden = sprintf("SELECT achternaam, voorletters, tussenvoegsels, aanhef_kort, huisadres_1, postcode_1, woonplaats_1, land_1, opgezegd, betalend_lid, overleden FROM tabel_leden WHERE overleden LIKE %s AND opgezegd LIKE %s AND betalend_lid LIKE %s", GetSQLValueString($colname1_rs_select_leden, "text"),GetSQLValueString($colname2_rs_select_leden, "text"),GetSQLValueString($colname3_rs_select_leden, "text"));
$rs_select_leden = mysql_query($query_rs_select_leden, $localhost) or die(mysql_error());
$row_rs_select_leden = mysql_fetch_assoc($rs_select_leden);
$totalRows_rs_select_leden = mysql_num_rows($rs_select_leden);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1"" />
<title>Untitled Document</title>
</head>
<body>
<table border="1" align="center">
<tr>
<td>achternaam</td>
<td>voorletters</td>
<td>tussenvoegsels</td>
<td>aanhef_kort</td>
<td>huisadres_1</td>
<td>postcode_1</td>
<td>woonplaats_1</td>
<td>land_1</td>
<td>opgezegd</td>
<td>betalend_lid</td>
<td>overleden</td>
</tr>
<?php do { ?>
<tr>
<td><a href="output_adressen_detail.php?recordID=<?php echo $row_rs_select_leden['achternaam']; ?>"> <?php echo $row_rs_select_leden['achternaam']; ?> </a> </td>
<td><?php echo $row_rs_select_leden['voorletters']; ?> </td>
<td><?php echo $row_rs_select_leden['tussenvoegsels']; ?> </td>
<td><?php echo $row_rs_select_leden['aanhef_kort']; ?> </td>
<td><?php echo $row_rs_select_leden['huisadres_1']; ?> </td>
<td><?php echo $row_rs_select_leden['postcode_1']; ?> </td>
<td><?php echo $row_rs_select_leden['woonplaats_1']; ?> </td>
<td><?php echo $row_rs_select_leden['land_1']; ?> </td>
<td><?php echo $row_rs_select_leden['opgezegd']; ?> </td>
<td><?php echo $row_rs_select_leden['betalend_lid']; ?> </td>
<td><?php echo $row_rs_select_leden['overleden']; ?> </td>
</tr>
<?php } while ($row_rs_select_leden = mysql_fetch_assoc($rs_select_leden)); ?>
</table>
<br>
<?php echo $totalRows_rs_select_leden ?> Records Total
</body>
</html>
<?php
mysql_free_result($rs_select_leden);
?>
Comments
Be the first to write a comment
You must me logged in to write a comment.