ETSoft Posted September 1, 2021 Share Posted September 1, 2021 Hi, the downlad script is working but when i try to pass an argument it is ignored. $firma= $_GET['argument1']; function Database_Connect() { $Host="localhost"; $Username=""; $Password=""; $dbName=""; $Error_Message=""; @$Connector=new mysqli($Host,$Username,$Password,$dbName); if(mysqli_connect_errno()) { $Error_Message="<br/><br/><div class='alert alert-danger'><i class='icon-remove-circle'></i>Sorry System '".$dbName."' Database Connection Failed to Initiate on this: ".$Host." Server, Username: ".$Username.".Please try again Later</div>"; die($Error_Message); exit(); } else { return $Connector; } } function MySql_Excel_Exporter() { $Excel_File = $firma . "-Export_Planning_".date("Y-m-d").".xls"; $Separator="\t"; /* Header info settings */ header("Content-Type: application/xls"); header("Content-Disposition: attachment; filename=".$Excel_File.""); header("Pragma: no-cache"); header("Expires: 0"); $MySqli=Database_Connect(); $Sql="SELECT * from table Where Responsibility ='". $firma ."'order by Activityid"; $Query=$MySqli->prepare($Sql); $Query->execute(); $Query->bind_result($....); print(trim("Activiteit"."".$Separator.""."O"."".$Separator.""."P"."".$Separator.""."S"."".$Separator.""."K"."".$Separator.""."LA")); print "\n"; while($Fetch=$Query->fetch()) { $Schema_Insert = ""; /* HERE I ACCEPT IF THERE IS A BETTER WAY OF JUST GETTING THE VALUES IN A FORM OF DYNAMIC WAY OF REFFERING COLUMS AS IN THE ORIGINAL CODE JUST USED LOOP TO GET COLUMNS, BUT AS I FDIDNT KNOW HOW TO DO THAT AND SO I USED WHAT I KNOW THE bind_result() AND JUST ASSIGN THEM TO $Schema_Insert FOR EXCEL FORMATING */ $Schema_Insert =$A."".$Separator."".$Ac."".$Separator."".$p."".$Separator."".$s."".$Separator."".$k."".$Separator."".$la."".$Separator.""; $Schema_Insert = str_replace($Separator."$", "", $Schema_Insert); $Schema_Insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $Schema_Insert); $Schema_Insert .= "\t"; print(trim($Schema_Insert)); print "\n"; } $Query->close(); } MySql_Excel_Exporter(); ?> (sensitive information is removed). Without the $firma variable it is working. Could someone help me on this one? Thanks in advance Erwin Quote Link to comment https://forums.phpfreaks.com/topic/313645-passing-an-argument-in-a-php-script-to-download-info-into-excel-not-working/ Share on other sites More sharing options...
gw1500se Posted September 1, 2021 Share Posted September 1, 2021 It is not ignored, it is not being passed anywhere. I suspect you meant to do this: function MySql_Excel_Exporter($firma) Quote Link to comment https://forums.phpfreaks.com/topic/313645-passing-an-argument-in-a-php-script-to-download-info-into-excel-not-working/#findComment-1589564 Share on other sites More sharing options...
ETSoft Posted September 1, 2021 Author Share Posted September 1, 2021 Yes this working, thank you Quote Link to comment https://forums.phpfreaks.com/topic/313645-passing-an-argument-in-a-php-script-to-download-info-into-excel-not-working/#findComment-1589565 Share on other sites More sharing options...
Barand Posted September 1, 2021 Share Posted September 1, 2021 You really make hard work of defining strings with all that concatenation and adding empty strings between everything. You could have just written $Schema_Insert ="$A\t$Ac\t$p\t$s\t$k\t$la"; eg $A = 'xyz'; $Ac = 'abc'; $p = 'mno'; $s = 123; $k = 456; $la = 'LA'; $Schema_Insert ="$A\t$Ac\t$p\t$s\t$k\t$la"; echo '<pre>'; echo $Schema_Insert; //--> xyz abc mno 123 456 LA echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/313645-passing-an-argument-in-a-php-script-to-download-info-into-excel-not-working/#findComment-1589567 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.