관리-도구
편집 파일: exportList.php
<? session_start(); $dbhost = 'internal-db.s3783.gridserver.com'; $dbusername = 'aaronmeyer'; $dbuserpassword = 'CQDZZDsu'; $default_dbname = 'db3783_ticketingSystem'; $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword); $dbid = mysql_select_db($default_dbname); if ($_POST['Submit']) { $fsql = "delete from temp_export"; $fres = mysql_query($fsql); $sql = "select * from bookingmaster where eventid='" . $_POST['eid'] . "'"; $res = mysql_query($sql); while ($row = mysql_fetch_row($res)) { $csql = "select * from personaldetails where id='" . $row[5] . "'"; $cres = mysql_query($csql); $crow = mysql_fetch_row($cres); $dsql = "select count(*) from bookingdetail where bookingid='" . $row[0] . "' and seatnumber > 0"; $dres = mysql_query($dsql); $drow = mysql_fetch_row($dres); $seatcount = $drow[0]; $dsql = "select * from bookingdetail where bookingid='" . $row[0] . "' and seatnumber > 0 order by seatnumber"; $dres = mysql_query($dsql); $seatdata = ""; while ($drow = mysql_fetch_row($dres)) { if ($drow[2] == 'General Seats') $seatdata .= 'General Admission, '; else { $seatdata .= "Reserve Admission - "; $rsql = "select * from eventseatingplan where id=" . $drow[3]; $rres = mysql_query($rsql); $rrow = mysql_fetch_row($rres); $seatdata .= substr($rrow[2],0,6) . ", "; } } if ($crow[0] != 0) $fsql = "insert into temp_export values ('".$row[0]."','".$crow[1]."','".$crow[4]."','".$crow[3]."','".$seatcount."','".$seatdata."')"; else $fsql = "insert into temp_export values ('".$row[0]."','Aaron Meyer Admin','','aaron@aaronmeyer.com','".$seatcount."','".$seatdata."')"; $fres = mysql_query($fsql); } $sql = "select id, name, phonenumber, emailaddress,countofseats,seatdetails from temp_export"; $res = mysql_query($sql); $incFileName = "excelwriter" . $_POST['eid'] . ".inc.php"; include($incFileName); $fileName = "Aaron_Meyer_2010.xls"; $excel = new ExcelWriter($fileName); if($excel==false) { echo $excel->error; die; } $myArr=array("<strong>Booking Id</strong>","<strong>Name</strong>","<strong>Phone Number</strong>","<strong>Email Address</strong>","<strong>Seat Count</strong>","<strong>Seat Details</strong>"); $excel->writeLine($myArr); while ($row = mysql_fetch_assoc($res)) { $excel->writeLine($row); } $excel->close(); header ("Expires: Mon, 31 Dec 2010 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: application/x-msexcel"); header ("Content-Disposition: attachment; filename=\"" . basename($fileName) . "\"" ); header ("Content-Description: PHP/INTERBASE Generated Data" ); readfile($fileName); } else {?> <!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> <style type="text/css"> <!-- .style1 { font-family: "Berlin Sans FB"; font-size: 18px; } .style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } --> </style> </head> <body><form id="form1" name="form1" method="post" action="exportList.php"> <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#333333"> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="6"> <tr> <td height="40" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><span class="style1">Export Reservation Data </span></td> </tr> <tr> <td width="48%" align="right" valign="middle" bgcolor="#FFFFFF"><span class="style4">Select Event</span></td> <td width="52%" align="left" valign="middle" bgcolor="#FFFFFF"> <select name="eid" id="eid"> <? $esql = "select * from eventmaster order by id"; $eres = mysql_query($esql); while ($erow = mysql_fetch_row($eres)) {?> <option value="<? echo $erow[0]; ?>"><? echo $erow[1] . " " . $erow[2]; ?></option> <? } ?> </select> </td> </tr> <tr> <td colspan="2" bgcolor="#FFFFFF"><div align="center"> <input type="submit" name="Submit" value=" Generate Excel Report " /> </div></td> </tr> </table> </td> </tr> </table></form> </body> </html> <? } ?>