ibanez270dx Posted August 9, 2006 Share Posted August 9, 2006 Hi, I think I can work my way around a perticular problem, but I don't know how it would translate to code... This is what I want to do:- First I want to extract some information from the database (pretty easy)[code=php:0]$sql = "SELECT * FROM downtime WHERE aircraft_id='$view_id' AND dwntime_year='$year' AND dwntime_month='$month' ORDER BY '$listorder'";[/code]- Next I want to create an array for every selected row[code=php:0]$therows .= array(<center>$dwntime_type</center>,<center>$dwntime_date</center>,<center>$dwntime_times</center>,<center>$dwntime_hrs</center>,<center>$dwntime_ata</center>,<center>$dwntime_reason</center>,<center>$dwntime_solution</center>,<center>$dwntime_log</center>,<center>$dwntime_log_by</center>);[/code]- Then I want to take each array and put some static code next to it (I know this is wrong, but you kinda get an idea)[code=php:0]$display = "$therows(but only 1 row at a time) $excel->writeLine($therows)";[/code]- That should be it. I am going to take that $display value and process it a little later in the script to make an Excel file. Any help is greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/17050-mixing-dynamic-w-static-variables/ Share on other sites More sharing options...
sasa Posted August 9, 2006 Share Posted August 9, 2006 1st[code]$therows[]=array("<center>$dwntime_type</center>","<center>$dwntime_date</center>","<center>$dwntime_times</center>","<center>$dwntime_hrs</center>","<center>$dwntime_ata</center>","<center>$dwntime_reason</center>","<center>$dwntime_solution</center>","<center>$dwntime_log</center>","<center>$dwntime_log_by</center>");[/code]2nd[code]$x='';foreach ($therows as $therow){$x .= "<p>".implode('<br />',$therow)."</p>";$y .= $excel->writeLine($therows)"; // i don't know what object do}echo $x;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17050-mixing-dynamic-w-static-variables/#findComment-71987 Share on other sites More sharing options...
ibanez270dx Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks for your help! However, my script still doesn't work. Here it is in it's entirety - including the new stuff:[code=php:0]<?phpinclude("excelwriter.inc.php");$view_id = "$_SESSION[aircraft_id]";$datename = "AMA - $year - $month";$filename = str_replace(' ', '', $datename);include("connect.php");$sql = "SELECT * FROM downtime WHERE aircraft_id='$view_id' AND dwntime_year='$year' AND dwntime_month='$month' ORDER BY '$listorder'";$result = @mysql_query($sql,$connection) or die(mysql_error());while ($row = mysql_fetch_array($result)) { $row_id = $row['row_id']; $dwntime_type = ucfirst(stripslashes($row['dwntime_type'])); $dwntime_hrs = round($row['dwntime_hrs'], 2); $dwntime_s = $row['dwntime_start']; $dwntime_e = $row['dwntime_end']; $dwntime_ata = $row['dwntime_ata']; $dwntime_reason = stripslashes($row['dwntime_reason']); $dwntime_solution = stripslashes($row['dwntime_solution']); $dwntime_log = $row['dwntime_log']; $dwntime_log_by = stripslashes($row['dwntime_log_by']); $dwntime_day = $row['dwntime_day']; $dwntime_month = $row['dwntime_month']; $dwntime_year = $row['dwntime_year']; $dwntime_times = "$dwntime_s - $dwntime_e"; $string = "$dwntime_year - $dwntime_month - $dwntime_day"; $dwntime_date = str_replace(' ', '', $string); $therows[]=array( "<center>$dwntime_type</center>", "<center>$dwntime_date</center>", "<center>$dwntime_times</center>", "<center>$dwntime_hrs</center>", "<center>$dwntime_ata</center>", "<center>$dwntime_reason</center>", "<center>$dwntime_solution</center>", "<center>$dwntime_log</center>", "<center>$dwntime_log_by</center>"); } $excel=new ExcelWriter("$filename.xls"); if($excel==false) echo $excel->error; $x=''; foreach ($therows as $therow) { $x .= "<p>".implode('<br />',$therow)."</p>"; $y .= $excel->writeLine($therows); } $myArr=array("<b>XOJET AMA</b>","<b><i>$monthname, $year</i></b>"); $excel->writeLine($myArr); $myArr=array("<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>","<font color=#FFFFFF>--------------------------</font>",); $excel->writeLine($myArr); $myArr=array("<center><b>Type</b></center>","<center><b>Date</b></center>","<center><b>Downtime</b></center>","<center><b>Hours Down</b></center>","<center><b>ATA</b></center>","<center><b>Discrepancy</b></center>","<center><b>Resolution</b></center>","<center><b>Logged</b></center>","<center><b>Logged By</b></center>"); $excel->writeLine($myArr); $excel->open($filename.xls); echo "Data has been written to $filename.xls successfully. <a href=$filename.xls>Click here</a><br><hr size=1><br>$x<br><hr size=1><p>$y";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17050-mixing-dynamic-w-static-variables/#findComment-72021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.