PHP - Pdo Data Seek / Read Ahead Problem
Hi,
I am trying to fetch a row in advance of the current one to find out if the next result is the same or not, and do something based on the outcome. I know how to do this with the old mysql functions like mysql_data_seek. What is the equivalent in PDO? I want the below sample to return row number 2, but it returns nothing no matter what number I set the offset to be. $readAhead = $resultParts->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_REL, 1) ; echo $readAhead['partNumber'] ; array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL) is set in my prepare statement. Similar TutorialsI'm converting a search feature that currently uses two successive dropdown fields to do the search. The search is initiated when the user selects the option from the dropdown. The resultant (it's always 1 record) is then displayed in detail with a + sign next to it so that the user can add the record he just searched for. I've replaced it with a single dropdown and type-ahead field that uses javascript. The type ahead replaces the second drop down. I didn't want users have to select amongst hundreds of records in a drop down, by forcing them to start typing the second drop down, I can narrow the results to the exact item the user is looking for. My problem is that I'm not sure how to get the type ahead result to initiate the search on the user select. I initiate it like this in the old version... <table> <tr> <td width="130px" valign="top"><form name="nav"><select name="platform" id="platform" onChange="document.location.href=document.nav.platform.options[document.nav.platform.selectedIndex].value"> <option>Platform</option> <? $result = mysql_query("SELECT * FROM Platform"); while($row = mysql_fetch_array($result)) { ?> <option value="?ptfm_ctrl=1&ptfm_id=<?=$row['id_platform']?>" <? if ($_GET['ptfm_id']==$row['id_platform']) { ?>selected="selected"<? } ?>><?=$row['platform']?></option> <? } ?> </select></form></td> <? if (isset($_GET["ptfm_ctrl"])) { ?> <tr> </table> The new solution generates the type ahead result like this... <div> <form> <div> Start typing the name of the product, select the correct title when it appears: <br /> <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" /> </div> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> </form> </div> How can I initiate the search using the second method? Hi! I am having trouble reading a stream of data being sent to my PC via PHP5. It seems that my code stops when it gets to the read section and just sits there indefinately. I am somewhat new to PHP so a solution and explanation would be great! Code: [Select] <?php $host = "129.000.00.01"; // host IP address $port = 40000; // port to listen to // sets script execution limit set_time_limit(30); // 0 means unlimited execution time (constant running) // create UDP socket $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die("Could not create UDP socket!\n"); // reset socket for binding if(!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) { echo "Failed to reset socket!\n"; } else echo "Reset socket successfully!\n"; // bind socket socket_bind($socket, $host, $port); // connect if (!socket_connect($socket, $host, $port)) { echo "Failed to connect to port!\n"; } else echo "Connected to port successfully!\n"; while (1) { echo socket_read($socket, 1024, PHP_NORMAL_READ)."\n"; } // close sockets socket_close($socket); echo "\nDone"; I need to search through a text file and output certain text. My current script doesn't work well at all. Code: [Select] <? $file = 'flist.txt'; $handle = @fopen($file, "r"); $names = array(); $func = array(); $desc = array(); $nme; $fnc; $dsc; $s = -1; $e = -1; $n = 0; if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { if($nme == 0) { if(strpos($buffer,"<a name") !== false) { $nme = 1; $s = strpos($buffer,"<a name"); } } else if($nme == 1) { if(strpos($buffer,"</span>") !== false) { $nme = 2; $e = strpos($buffer,"</span>"); $num = $e - $s; $names[$n] = strip_tags(substr($buffer,$s,$num)); } } else if($nme == 2) { if($fnc == 0) { if(strpos($buffer,"<table style") !== false) { $fnc = 1; $s = strpos($buffer,"<table style"); } } else if($fnc == 1) { if(strpos($buffer,"</td>") !== false) { $fnc = 2; $e = strpos($buffer,"</td>"); $num = $e - $s; $func[$n] = strip_tags(substr($buffer,$s,$num)); } } else if($fnc == 2) { if($dsc == 0) { if(strpos($buffer,"<p>") !== false) { $dsc = 1; $s = strpos($buffer,"<p>"); } } else if($dsc == 1) { if(strpos($buffer,"</p>") !== false) { $fnc = 0; $nme = 0; $dsc = 0; $e = strpos($buffer,"</p>"); $num = $e - $s; $desc[$n] = strip_tags(substr($buffer,$s,$num)); } } } } } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); $n = 0; while($n < 100) { echo $names[$n] . "<br>"; echo $func[$n] . "<br>"; echo $desc[$n] . "<p>"; $n ++; } } ?> 4096 gets the data for each line, right? Well some of my data uses two lines. After all the searching is done I need it to output $names, $func, and $desc in plain text. Hey guys, The script I use to generate images, more or less, works almost flawlessly. However, I keep experiencing a problem at random in my script when it comes time to call a JPEG or PNG file from an external server. A lot of the time it will work fine, but many other times it comes back with the error: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Cannot read image data Which causes the script to fail. Right now the images it say it cannot read are these: http://tiles.xbox.com/tiles/UT/EF/1mdsb2JgbA9ECgQLGwMfWSkgL2ljb24vMC84MDAwIAABAAAAAPkqMU4=.jpg http://tiles.xbox.com/tiles/Au/lM/1Wdsb2JgbA9ECgUAGwEfL1hTL2ljb24vMC84MDAwIAABAAAAAPpj6R0=.jpg http://tiles.xbox.com/tiles/6q/kv/1Gdsb2JgbA9ECgUAGwEfL1hSL2ljb24vMC84MDAwIAABAAAAAPsAqfU=.jpg http://tiles.xbox.com/tiles/tQ/UG/1Gdsb2JgbA9ECgUAGwEfV1gmL2ljb24vMC84MDAwIAABAAAAAPspBao=.jpg http://tiles.xbox.com/tiles/qp/Fx/0Wdsb2JgbA9ECgQNGwEfVitXL2ljb24vMC84MDAwIAABAAAAAP5ekbU=.jpg and as you can see, they work fine. So what's going on here? Is Microsoft somehow blocking the attempt? I can view the images fine in the browser, but sometimes it just won't work in the script. But like I said, it's not everytime. The line the errors comes up on are these: $lastxboxgames = imagecreatefromjpeg($lastxboxgames); $lastxboxgames1 = imagecreatefromjpeg($lastxboxgames1); $lastxboxgames2 = imagecreatefromjpeg($lastxboxgames2); $lastxboxgames3 = imagecreatefromjpeg($lastxboxgames3); $lastxboxgames4 = imagecreatefromjpeg($lastxboxgames4); I also have the script to echo the variables back to me when while it's running, so those urls up there came exactly from the script, so it's not that its getting the wrong URL, it just decides that the image isn't good enough. The script, generates my signature image below, and when any of the images that come from the xbox server return an error, they all do, including the avatar image in the top left which is a PNG. Any help is appreciated! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=352249.0 hi, i have the class here, and am trying to save the read column of the textfile to db. but unfortunately it's not being save, i don't know what's wrong... I also attached the textfile so you'll have an idea what am i trying to read from class Extractor { public $filehandler; public $data = array(); // set your db access details private $host = HOST; private $username = USERNAME; private $password = PASSWORD; private $dbname = DBNAME; public function __construct($file) { $this->filehandler = $file; } //prints col1 of textfile public function printcol1() { $fp = fopen($this->filehandler,'r'); while(($this->data = fgetcsv($fp,1000,",")) !== FALSE) { # $this->data[0]."<br />"; $this->savetodb($this->data[0]); } fclose($fp); } public function savetodb($data) { try{ $pdo = new PDO("mysql:host=$this->host;dbname=$this->dbname",$this->username,$this->password); $pdo->exec("INSERT INTO test(col,id) VALUES ({$data},null)"); $pdo = null; }catch(PDOException $e){ echo $e->getMessage()."<br />"; } } } $file = 'iso3166.txt'; $shit = new Extractor($file); $shit->printcol1(); <?php ini_set('display_errors', 0); function escapeArray($array) { foreach ($array as $key => $val) { if(is_array($val)){ $array[$key]=escapeArray($val); } else{ $array[$key]=addslashes($val); } } return $array; } $request_type=$_SERVER['REQUEST_METHOD']; $api_key=$_SERVER['HTTP_X_API_KEY']; $res=array(); if($api_key!=="643256432"){ $res['msg']="Failu Invalid API KEY"; echo json_encode($res); die; } // Connects to the orcl service (i.e. database) on the "localhost" machine //$conn = oci_connect('SCOTT', 'admin123', 'localhost/orcl'); $conn = oci_connect('test', 'test', '192.168.10.43/test.test.com'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $request=file_get_contents("php://input"); $request=escapeArray(json_decode($request,true)); print_r($request); // die; if($request_type=="POST"){//for creation of invoice echo $CONTACT_ID=isset($request['CONTACT_ID'])?$request['CONTACT_ID']:""; $INV_SERIAL_NO=isset($request['INV_SERIAL_NO'])?$request['INV_SERIAL_NO']:""; $NAME=isset($request['NAME'])?$request['NAME']:""; $INV_DATE=isset($request['INV_DATE'])?$request['INV_DATE']:""; $DUE_DATE=isset($request['DUE_DATE'])?$request['DUE_DATE']:""; $CURRENCY=isset($request['CURRENCY'])?$request['CURRENCY']:""; $SUBTOTAL=isset($request['SUBTOTAL'])?$request['SUBTOTAL']:""; $TAX_TOTAL=isset($request['TAX_TOTAL'])?$request['TAX_TOTAL']:""; echo $SHIP_SERIAL_NO=isset($request['SHIP_SERIAL_NO'])?$request['SHIP_SERIAL_NO']:""; $MASTER_NO=isset($request['MASTER_NO'])?$request['MASTER_NO']:""; $HOUSE_NO=isset($request['HOUSE_NO'])?$request['HOUSE_NO']:""; $shipment_data=isset($request['shipment_data'])?$request['shipment_data']:""; if($CONTACT_ID==""){ $res['msg']="CONTACT_ID is required"; } else if($INV_SERIAL_NO==""){ $res['msg']="INV_SERIAL_NO is required"; } else if($NAME==""){ $res['msg']="NAME is required"; } else if($INV_DATE==""){ $res['msg']="INV_DATE is required"; } else if($DUE_DATE==""){ $res['msg']="DUE_DATE is required"; } else if($CURRENCY==""){ $res['msg']="CURRENCY is required"; } else if($SUBTOTAL==""){ $res['msg']="SUBTOTAL is required"; } else if($TAX_TOTAL==""){ $res['msg']="TAX_TOTAL is required"; } else if($MASTER_NO==""){ $res['msg']="MASTER_NO is required"; } else if($HOUSE_NO==""){ $res['msg']="HOUSE_NO is required"; } else if($SHIP_SERIAL_NO==""){ $res['msg']="SHIP_SERIAL_NO is required"; } else{ $stid = oci_parse($conn, "Select * from FL_HDR_INVOICE where CONTACT_ID='$CONTACT_ID'"); (oci_execute($stid)); oci_fetch_all($stid, $out); if(count($out['CONTACT_ID'])==0){ $stid = oci_parse($conn, "Insert into FL_HDR_INVOICE (CONTACT_ID,INV_SERIAL_NO,NAME,INV_DATE,DUE_DATE,CURRENCY,SUBTOTAL,TAX_TOTAL) Values ('$CONTACT_ID','$INV_SERIAL_NO','$NAME',TO_DATE('$INV_DATE','YYYY-MM-DD'),TO_DATE('$DUE_DATE','YYYY-MM-DD'),'$CURRENCY','$SUBTOTAL','$TAX_TOTAL')"); oci_execute($stid); $stid_2 = oci_parse($conn, "Insert into FL_SHIPMENT_DATA (CONTACT_ID,INV_SERIAL_NO,SHIP_SERIAL_NO,MASTER_NO,HOUSE_NO) Values ('$CONTACT_ID','$INV_SERIAL_NO','$SHIP_SERIAL_NO','$MASTER_NO','$HOUSE_NO')"); oci_execute($stid_2); if(oci_num_rows($stid)>0){ $res['msg']="Invoice created successfully against this contact_id:".$CONTACT_ID; } else{ $res['msg']="Something going wrong please try again later"; } } else{ $res['msg']="contact_id must be unique"; } } echo json_encode($res); die; } I need to read json data inside an array. Please help correct my code.. i am trying to do an API. After searching postings on multiple forums, I am officially now "Freaking OUT" trying to understand something that is probably very simple, but cannot seem to grasp. I simply want to read basic .csv data that is sent/uploaded directly to a PHP page, and to then append each record that shows up to a single .csv file on the server. The incoming data is supposed incoming via $_POST['csv'] ... at least that's what I was told. Each.csv record line being sent/uploaded is very simple (either single or multiple records in one small file): text1,text2,text3,text4,text5 For additional processing I know about 'explode', etc., but right now I am stuck even trying to do an 'echo' to display the simple incoming data "as is". One option I tried was: $postdata = file_get_contents("php://input"); echo $postdata; In the Java App monitoring I get the following after 3 records are sent/uploaded to the PHP URL: Server response status line: HTTP/1.1 200 OK I find this strange since I did not include... http_response_code(200); ... in the page code. Obviously, I do NOT know what I am doing here {SIGH}. Any assistance or guidance is appreciated. Thank you ! - FreakingOUT
I'm trying to send some POST data to a page and then get the contents of it. The page is not on my server, so I can't use Sessions or GET. Google hasn't provided me with a definite answer. How would I do this? Our professor in PHP Programming is very choosy that he requires us to verify if the user enter the UPPERCASE format of the user name registered the program will show an invalid user. What he's trying to say is the user must enter a 100% identical to the username he registered. If the username registered is LOWERCASE he must enter a LOWERCASE username if the username registered is UPPERCASE he must enter an UPPERCASE username to LOGIN. Hello,
I try to get website speed of some website, but i can read only ''domain.com'' i can't read website files like css , js ... why ? i use proxies for this job.
here is the php code:
$options = array( 'useragent' => "Firefox (+http://www.firefox.org)", // who am i 'connecttimeout' => 120, // timeout on connect 'timeout' => 120, // timeout on response 'redirect' => 10, // stop after 10 redirects 'referer' => "http://www.google.com", 'proxyhost' =>'85.25.8.14:80' ); $response = http_get("http://solve-ict.com/wp-content/themes/ict%20theme/js/jquery-1.7.1.min.js", $options , $info);but it works fine with http://domain.com/ , but with files css or js it gives 404, using some free proxy servers available ? Thanks. Is there a code library out there that can read the exif data from image files, without the use of the php exif extension? I have a Windows hosting package and am noticing that several hosts don't (and won't) enable the exif extension for PHP for some reason. I need Windows for one of my sites which requires MS SQL access, so I can't use a Unix/Linux host because of that. But all of them support PHP on Windows.
Suggestions?
Trying to get this done: Page_1 has many external links, when certain links are clicked i do not want user to go directly to page, but rather go to a special add page_2 where user must click a second time on the link to finally get there. The add page_2 must show on screen the name of the initial link from page_1, it must change accordingly with the link it came from page_1,once on page_2 the hyperlink redirects outside the site. So far i am thinking give an id to the div or "<a href..." on page_1 then somehow have page_2 detect that id and fill in the variable for the final external link. Other wise is there a way to detect a url from incoming? I guess a similar example is how some domain name sellers landing page will indicate the name of the site. Such as "Thisdomain.com" is for sale. same landing page but the name changes according to the domain that was typed. I got a question im using izabi for me im one who loves the software. But there some quirks that they forgot to add when making the mail system. I was wondering how it would be possible to code in a peice of php where it says read after someone read the email. If you need a copy of the mail mail script let me know. Hi... I create a payroll system and now I have an issue or problem in saving data before I save data using save button now i want to save data when clicking the employee name at the navigalist list from the left side. Here is my code for the searching and displaying employee name at navigation list: Here is my code for search.php: Code: [Select] <?php session_start(); include 'config.php'; $queryString = $_GET["query"]; if ($queryString == "" || $queryString == null) { $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL ORDER BY FULLNAME ASC"; } else { $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') LIKE '" . $queryString . "%' ORDER BY FULLNAME ASC"; } $recPersonalQuery = $conn->Execute($sql); if (!$recPersonalQuery->BOF) { $recPersonalQuery->MoveFirst(); } echo "<hr />"; echo "<ul>"; while (!$recPersonalQuery->EOF) { $empID = $recPersonalQuery->fields["EMP_ID"]; $empFullName = $recPersonalQuery->fields["FULLNAME"]; echo "<li onclick=changeEmployeePay('$empID'); >$empFullName</li>"; //echo "<li onkeyup=changeEmployeePay('$empID'); >$empFullName</li>"; echo "<hr />"; $recPersonalQuery->MoveNext(); } echo "</ul>"; $recPersonalQuery->Close(); exit(); ?> here is the javascript code and the template for displaying employee name list: Code: [Select] <html> <head> <title></title> <script> function searchemppay(queryString) { var ajaxRequest = remoteRequestObject(); ajaxRequest.onreadystatechange = function() { if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) { var result = ajaxRequest.responseText; document.getElementById('searchpayroll').innerHTML = result; } } var url = "search.php?query=" + queryString; ajaxRequest.open("GET", url, true); ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); ajaxRequest.send(null); } function changeEmployeePay(queryID) { window.location = "SearchData.php?queryEmpID=" + queryID; } </script> </head> <body> <div id="Search"> <form> <p class="serif"><b>Search Lastname:</b></p> <input type="text" name="search_" size="20" onkeyup="searchemppay(this.value);"> <div id="searchpayroll" style="overflow:auto; height:390px; width:auto; margin-left:2px" > <hr /> <ul> {section name=co_emp loop=$personalAll} <li onclick="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li> <!--<li onkeyup="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li>--> <hr /> {sectionelse} <li>No records found</li> {/section} </ul> </div> </div> </body> </html> and here is the code for displaying employee data Code: [Select] <?php include 'config.php'; $currentEmpID = $_SESSION['empID']; $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC"; $recPersonalNav = $conn->GetAll($sql); $smarty->assign('personalAll', $recPersonalNav); $EMP_NO = $_POST['EMP_NO']; $sql = "SELECT em.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL p, EMPLOYMENT em WHERE p.EMP_ID='$currentEmpID' AND em.EMP_ID = '$currentEmpID'"; $recPersonalHead = $conn->Execute($sql); $fullName = $recPersonalHead->fields["FULLNAME"]; $empno = $recPersonalHead->fields["EMP_NO"]; $smarty->assign('empid', $currentEmpID); $smarty->assign('fullname', $fullName); $smarty->assign('empno', $empno); $sql = "SELECT EMP_ID, RATE FROM wage WHERE EMP_ID = '$currentEmpID'"; $rsWage = $conn->Execute($sql); $Rate = $rsWage->fields['RATE']; $sql = "SELECT EMP_ID,EMP_NO, STATUS FROM employment WHERE EMP_ID = '$currentEmpID'"; $rsStatus = $conn->Execute($sql); $STATUS = $rsStatus->fields['STATUS']; $EMP_ID = $rsStatus->fields['EMP_ID']; $sql = "SELECT em.EMP_NO, em.STATUS, w.RATE, r.Hours, o.OT_Hours FROM $ADODB_DB.employment AS em INNER JOIN $ADODB_DB.wage AS w ON em.EMP_ID = w.EMP_ID LEFT JOIN $PAYROLL.regular_sum_hours AS r ON em.EMP_NO = r.EMP_NO LEFT JOIN $PAYROLL.ot_data AS o ON r.EMP_NO = o.EMP_NO WHERE em.EMP_ID = '$currentEmpID' AND o.STATUS = 'Offset'"; $RsEarnings = $conn2->Execute($sql); $Rate = $RsEarnings->fields['RATE']; $Hours = $RsEarnings->fields['Hours']; $Offset = $RsEarnings->fields['OT_Hours']; $Hours = substr($Hours, 0, 5); $Hours = str_replace(':', '.', $Hours); $Hours = ($Hours + $Offset); $Amount = $_POST["Amount"]; $Amount = round(($Hours/8)* $Rate, 2); $smarty->assign('Rate', $Rate); $smarty->assign('Hours', $Hours); $smarty->assign('Amount', $Amount); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours, o.STATUS FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'RegularOvertime' AND o.STATUS = 'Overtime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $OTReg_Hours = $rsOTData->fields['OT_Hours']; $OTReg_Hours = round($OTReg_Hours, 2); $OTReg_Amt = round((($Rate / 8 * 1.3) * $OTReg_Hours), 2); $smarty->assign('OTReg_Hours', $OTReg_Hours); $smarty->assign('OTReg_Amt', $OTReg_Amt); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'SundayRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $SunReg_Hours = $rsOTData->fields['OT_Hours']; $SunReg_Hours = round($SunReg_Hours, 2); $SunReg_Amt = round((($Rate / 8 * 1.35) * $SunReg_Hours), 2); $smarty->assign('SunReg_Hours', $SunReg_Hours); $smarty->assign('SunReg_Amt', $SunReg_Amt); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'SundayOvertime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $OTSun_Hours = $rsOTData->fields['OT_Hours']; $OTSun_Hours = round($OTSun_Hours, 2); $OTSun_Amt = round((($Rate / 8 * 1.35 * 1.35) * $OTSun_Hours), 2); $smarty->assign('OTSun_Hours', $OTSun_Hours); $smarty->assign('OTSun_Amt', $OTSun_Amt); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'HolidayRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $HolReg_Hours = $rsOTData->fields['OT_Hours']; $HolReg_Hours = round($HolReg_Hours, 2); $HolReg_Amt = round((($Rate / 8 * 1.5) * $HolReg_Hours), 2); $smarty->assign('HolReg_Hours', $HolReg_Hours); $smarty->assign('HolReg_Amt', $HolReg_Amt); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'HolidayRegularOvertime' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $HolRegOT_Hours = $rsOTData->fields['OT_Hours']; $HolRegOT_Hours = round($HolRegOT_Hours, 2); $HolRegOT_Amt = round((($Rate / 8 * 2.05 * 1.35) * $HolRegOT_Hours), 2); $smarty->assign('HolRegOT_Hours', $HolRegOT_Hours); $smarty->assign('HolRegOT_Amt', $HolRegOT_Amt); $sql = "SELECT em.EMP_NO, SUM(l.HOURS_LEAVE) AS HOURS_LEAVE FROM $PAYROLL.leave_data l, $ADODB_DB.employment em WHERE em.EMP_NO = l.EMP_NO AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $HolLeave_Hours = $rsOTData->fields['HOURS_LEAVE']; $HolLeave_Hours = round($HolLeave_Hours, 2); $HolLeave_Amt = round((($Rate) * $HolLeave_Hours), 2); $smarty->assign('HolLeave_Hours', $HolLeave_Hours); $smarty->assign('HolLeave_Amt', $HolLeave_Amt); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumRegular' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $NPReg_Hours = $rsOTData->fields['OT_Hours']; $NPReg_Hours = round($NPReg_Hours, 2); $NPReg_Amt = round((($Rate / 8 * 0.15) * $NPReg_Hours), 2); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumSunday' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $NPSun_Hours = $rsOTData->fields['OT_Hours']; $NPSun_Hours = round($NPSun_Hours, 2); $NPSun_Amt = round((($Rate / 8 * 1.35 * 0.15) * $NPSun_Hours), 2); $sql = "SELECT em.EMP_NO, o.OT_Category, SUM(OT_Hours) AS OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category = 'NightPremiumHoliday' AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $NPHol_Hours = $rsOTData->fields['OT_Hours']; $NPHol_Hours = round($NPHol_Hours, 2); $NPHol_Amt = round((($Rate / 8 * 2.05 * 0.15) * $NPHol_Hours), 2); $NP_Hours = round(($NPReg_Hours + $NPSun_Hours + $NPHol_Hours), 2); $NP_Hours = round($NP_Hours, 2); $NP_Amt = round(($NPReg_Amt + $NPSun_Amt + $NPHol_Amt), 2); $smarty->assign('NP_Hours', $NP_Hours); $smarty->assign('NP_Amt', $NP_Amt); $sql = "SELECT COUNT(o.EMP_NO) AS EMP_NO, o.OT_Category, o.OT_Hours, o.STATUS FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category IN ('RegularOvertime', 'HolidayRegular', 'HolidayRegularOvertime') AND o.OT_Hours > 2 AND em.EMP_ID = '$currentEmpID' AND o.STATUS = 'Overtime' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $MealReg_Hours = $rsOTData->fields['EMP_NO']; $MealReg_Hours = round($MealReg_Hours, 2); $MealReg_Amt = round(($MealReg_Hours * 23), 2); $sql = "SELECT COUNT(o.EMP_NO) AS EMP_NO, o.OT_Category, o.OT_Hours FROM $PAYROLL.ot_data o, $ADODB_DB.employment em WHERE em.EMP_NO = o.EMP_NO AND o.OT_Category IN ('SundayRegular', 'SundayOvertime') AND o.OT_Hours > 2 AND em.EMP_ID = '$currentEmpID' GROUP BY em.EMP_NO"; $rsOTData = $conn2->Execute($sql); $MealSun_Hours = $rsOTData->fields['EMP_NO']; $MealSun_Hours = round($MealSun_Hours, 2); $MealSun_Amt = round(($MealSun_Hours * 30), 2); $Meal_Hours = round(($MealReg_Hours + $MealSun_Hours), 2); $Meal_Amt = round(($MealReg_Amt + $MealSun_Amt), 2); $smarty->assign('Meal_Hours', $Meal_Hours); $smarty->assign('Meal_Amt', $Meal_Amt); $sql = "SELECT COUNT(a.EMP_NO) AS EMP_NO, w.RATE FROM $ADODB_DB.wage w, $ADODB.employment em, $PAYROLL.attendance a WHERE em.EMP_NO = a.EMP_NO AND w.RATE = 302 AND em.EMP_ID = '$currentEmpID' GROUP BY w.RATE"; $rsOTData = $conn2->Execute($sql); $Cola_Hours = $rsOTData->fields['EMP_NO']; $Cola_Hours = round($Cola_Hours, 2); $Cola_Amt = round(($Cola_Hours * 28), 2); $smarty->assign('Cola_Hours', $Cola_Hours); $smarty->assign('Cola_Amt', $Cola_Amt); $TotEarn = $_POST['TotEarn']; $TotEarn = round(($Amount + $OTReg_Amt + $SunReg_Amt + $OTSun_Amt + $HolReg_Amt + $HolRegOT_Amt + $HolLeave_Amt + $NP_Amt + $Meal_Amt + $Cola_Amt), 2); $smarty->assign('TotEarn', $TotEarn); $HDMF = $_POST['HDMF']; $sql = "SELECT Ref_No, Range FROM $PAYROLL.hdmf, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $rs = $conn2->Execute($sql); $Range = $rs->fields['Range']; if ($TotEarn <= $Range) { $HDMF = round(($TotEarn * 0.01), 2); } else { $HDMF = round(($TotEarn * 0.02), 2); } $smarty->assign('HDMF', $HDMF); $SSS = $_POST['SSS']; $sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range"; $rs = $conn2->Execute($sql); $SSS = $rs->fields['Employee_Share']; $smarty->assign('SSS', $SSS); $PCHL = $_POST['PCHL']; $sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.pchl, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range"; $rs = $conn2->Execute($sql); $PCHL = $rs->fields['Employee_Share']; $smarty->assign('PCHL', $PCHL); $TAX = $_POST['TAX']; $sql = "SELECT EMP_ID, EMP_NO, W4_STATUS, DEPENDENTS FROM employment WHERE EMP_ID = '$currentEmpID'"; $rsTax = $conn->Execute($sql); $W4_STATUS = $rsTax->fields['W4_STATUS']; $DEPENDENTS = $rsTax->fields['DEPENDENTS']; if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 0 AND $TotEarn <= 2083){ $TAX = round($TotEarn * .05); } elseif($W4_STATUS == 2 AND $DEPENDENTS == 0 AND $TotEarn >= 0 AND $TotEarn <= 2083){ $TAX = round($TotEarn * .05); } elseif($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 2083 AND $TotEarn <= 2500) { $TAX = round($TotEarn - 2083); $TAX = round(20.83 + ($TAX * .10)); } elseif($W4_STATUS == 2 AND $DEPENDENTS == 0 AND $TotEarn >= 2083 AND $TotEarn <= 2500) { $TAX = round($TotEarn - 2083); $TAX = round(20.83 + ($TAX * .10)); } elseif($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 2500 AND $TotEarn <= 3333) { $TAX = round($TotEarn - 2500); $TAX = round(104.17 + ($TAX * .15)); } else{ $TAX = round(0); } $smarty->assign('TAX', $TAX); $sql = "SELECT s.EMP_NO, s.SSSAmor FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO = s.EMP_NO AND em.EMP_ID = '$currentEmpID'"; $RsDed = $conn2->Execute($sql); $SSSAmor = round($RsDed->fields['SSSAmor']); $sql = "SELECT h.EMP_NO, h.HDMFAmor FROM $PAYROLL.hdmfloan h, $ADODB_DB.employment em WHERE em.EMP_NO = h.EMP_NO AND em.EMP_ID = '$currentEmpID'"; $RsHDMF = $conn2->Execute($sql); $HDMFAmor = round($RsHDMF->fields['HDMFAmor']); $sql = "SELECT u.EMP_NO, u.UDTAmor FROM $PAYROLL.udtloan u, $ADODB_DB.employment em WHERE em.EMP_NO = u.EMP_NO AND em.EMP_ID = '$currentEmpID'"; $RsUDT = $conn2->Execute($sql); $UDTAmor = round($RsUDT->fields['UDTAmor']); $TotalDed = $_POST['TotalDed']; $sql = "SELECT o.EMP_NO, o.BurialSeparationCont, o.TaxAjt, o.CashAdvance, o.AdvanceShirt, o.AdvanceMed, o.AdvanceOther FROM $PAYROLL.other_deductions o, $ADODB_DB.personal p, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND em.EMP_NO = o.EMP_NO"; $rsOtherDed = $conn2->Execute($sql); $BurialSep = round($rsOtherDed->fields['BurialSeparationCont']); $TaxAjt = round($rsOtherDed->fields['TaxAjt']); $CashAdvance = round($rsOtherDed->fields['CashAdvance']); $AdvancesShirt = round($rsOtherDed->fields['AdvanceShirt']); $AdvancesMed = round($rsOtherDed->fields['AdvanceMed']); $AdvancesOthers = round($rsOtherDed->fields['AdvanceOther']); $smarty->assign('BurialSep', $BurialSep); $smarty->assign('TaxAjt', $TaxAjt); $smarty->assign('CashAdvance', $CashAdvance); $smarty->assign('AdvancesShirt', $AdvancesShirt); $smarty->assign('AdvancesMed', $AdvancesMed); $smarty->assign('AdvancesOthers', $AdvancesOthers); $TotalDed = round(($SSS + $HDMF + $PCHL + $TAX + $SSSAmor + $HDMFAmor + $UDTAmor + $BurialSep + $TaxAjt + $CashAdvance + $AdvancesShirt + $AdvancesMed + $AdvancesOthers), 2); $smarty->assign('SSSAmor', $SSSAmor); $smarty->assign('HDMFAmor', $HDMFAmor); $smarty->assign('UDTAmor', $UDTAmor); $smarty->assign('TotalDed', $TotalDed); $THP = $_POST["TakeHomePay"]; $THP = round($TotEarn - $TotalDed, 2); $smarty->assign('THP', $THP); $sql = "SELECT EMP_NO, OTReg_Amt, SunReg_Amt, OTSun_Amt, HolReg_Amt, HolRegOT_Amt, HolLeave_Amt, NP_Amt, Meal_Amt, Cola_Amt FROM other_earnings WHERE EMP_NO = '$empno'"; $RsOtherEarnings = $conn2->Execute($sql); $numrowsOtherEarnings = $RsOtherEarnings->RecordCount(); if($numrowsOtherEarnings > 0){ $saverec['EMP_NO'] = $empno; $saverec['OTReg_Amt'] = $OTReg_Amt; $saverec['SunReg_Amt'] = $SunReg_Amt; $saverec['OTSun_Amt'] = $OTSun_Amt; $saverec['HolReg_Amt'] = $HolReg_Amt; $saverec['HolRegOT_Amt'] = $HolRegOT_Amt; $saverec['HolLeave_Amt'] = $HolLeaveAmt; $saverec['NP_Amt'] = $NP_Amt; $saverec['Meal_Amt'] = $Meal_Amt; $saverec['Cola_Amt'] = $Cola_Amt; $updateOtherEarnings = $conn2->GetUpdateSQL($RsOtherEarnings, $saverec); $conn2->Execute($updateOtherEarnings); } else{ $sql = "SELECT o.EMP_NO, o.OTReg_Amt, o.SunReg_Amt, o.OTSun_Amt, o.HolReg_Amt, o.HolRegOT_Amt, o.HolLeave_Amt, o.NP_Amt, o.Meal_Amt, o.Cola_Amt FROM $PAYROLL.other_earnings o, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $RsOtherEarnings = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['OTReg_Amt'] = $OTReg_Amt; $saverec['SunReg_Amt'] = $SunReg_Amt; $saverec['OTSun_Amt'] = $OTSun_Amt; $saverec['HolReg_Amt'] = $HolReg_Amt; $saverec['HolRegOT_Amt'] = $HolRegOT_Amt; $saverec['HolLeave_Amt'] = $HolLeaveAmt; $saverec['NP_Amt'] = $NP_Amt; $saverec['Meal_Amt'] = $Meal_Amt; $saverec['Cola_Amt'] = $Cola_Amt; $insertOtherEarnings = $conn2->GetInsertSQL($RsOtherEarnings, $saverec); $conn2->Execute($insertOtherEarnings); } $sql = "SELECT EMP_NO, SSS, TAX, PCHL, HDMF FROM deductions WHERE EMP_NO = '$empno'"; $RsDeduction = $conn2->Execute($sql); $numrowsDeduction = $RsDeduction->RecordCount(); if($numrowsDeduction > 0){ $saverec['EMP_NO'] = $empno; $saverec['SSS'] = $SSS; $saverec['TAX'] = $TAX; $saverec['PCHL'] = $PCHL; $saverec['HDMF'] = $HDMF; $updateDeductionSQL = $conn2->GetUpdateSQL($RsDeduction, $saverec); $conn2->Execute($updateDeductionSQL); } else{ $sql = "SELECT d.EMP_NO, d.SSS, d.TAX, d.PCHL, d.HDMF FROM $PAYROLL.deductions d, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $RsDeduction = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['SSS'] = $SSS; $saverec['TAX'] = $TAX; $saverec['PCHL'] = $PCHL; $saverec['HDMF'] = $HDMF; $insertSQL = $conn2->GetInsertSQL($RsDeduction, $saverec); $conn2->Execute($insertSQL); } $sql = "SELECT EMP_NO, SSSLoan, HDMFLoan, UDTLoan FROM loan_deductions WHERE EMP_NO = '$empno'"; $RsLoan = $conn2->Execute($sql); $numrowsRsLoan = $RsLoan->RecordCount(); if($numrowsRsLoan > 0){ $saverec['EMP_NO'] = $empno; $saverec['SSSLoan'] = $SSSAmor; $saverec['HDMFLoan'] = $HDMFAmmor; $saverec['UDTLoan'] = $UDTAmor; $updateLoanSQL = $conn2->GetUpdateSQL($RsLoan, $saverec); $conn2->Execute($updateLoanSQL); } else{ $sql = "SELECT l.EMP_NO, l.SSSLoan, l.HDMFLoan, l.UDTLoan FROM $PAYROLL.loan_deductions l, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $RsLoan = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['SSSLoan'] = $SSSAmor; $saverec['HDMFLoan'] = $HDMFAmor; $saverec['UDTLoan'] = $UDTAmor; $insertSQL = $conn2->GetInsertSQL($RsLoan, $saverec); $conn2->Execute($insertSQL); } $sql = "SELECT EMP_NO, Amount, TotalEarnings, TotalDeductions, TakeHomePay FROM totalpay WHERE EMP_NO = '$empno'"; $rsTotal = $conn2->Execute($sql); $numrows = $rsTotal->RecordCount(); if($numrows > 0){ $saverec['EMP_NO'] = $empno; $saverec['Amount'] = $Amount; $saverec['TotalEarnings'] = $TotEarn; $saverec['TotalDeductions'] = $TotalDed; $saverec['TakeHomePay'] = $THP; $updateSQL = $conn2->GetUpdateSQL($rsTotal, $saverec); $conn2->Execute($updateSQL); } else{ $sql = "SELECT t.EMP_NO, t.Amount, t.TotalEarnings, t.TotalDeductions, t.TakeHomePay FROM $PAYROLL.totalpay t, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $rsTotal = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['Amount'] = $Amount; $saverec['TotalEarnings'] = $TotEarn; $saverec['TotalDeductions'] = $TotalDed; $saverec['TakeHomePay'] = $THP; $insertSQL = $conn2->GetInsertSQL($rsTotal, $saverec); $conn2->Execute($insertSQL); } $smarty->display('header.tpl'); $smarty->display('left.tpl'); $smarty->display('empPayrollData.tpl'); $smarty->display('footer.tpl'); ?> I have a problem in saving data from other deductions and the total deductions and takehomepay, because other deductions is insertable textfield and when I add other deductions the total deductions will change also the Take Home Pay. Idon't know where Can I add this code for saving data of other deductions and updating the changes if Total Deductions and Take Home Pay. Code: [Select] $sql = "SELECT EMP_NO, BurialSeparationCont, TaxAjt, CashAdvance, AdvanceShirt, AdvanceMed, AdvanceOther FROM other_deductions WHERE EMP_NO = '$empno'"; $rsOtherDed = $conn2->Execute($sql); $numrows1 = $rsOtherDed->RecordCount(); if($numrows1 > 0){ $saverec['EMP_NO'] = $empno; $saverec['BurialSeparationCont'] = $BurialSep; $saverec['TaxAjt'] = $TaxAjt; $saverec['CashAdvance'] = $CashAdvance; $saverec['AdvanceShirt'] = $AdvancesShirt; $saverec['AdvanceMed'] = $AdvancesMed; $saverec['AdvanceOther'] = $AdvancesOthers; $updateSQL = $conn2->GetUpdateSQL($rsOtherDed, $saverec); $conn2->Execute($updateSQL); } else{ $sql = "SELECT o.EMP_NO, o.BurialSeparationCont, o.TaxAjt, o.CashAdvance, o.AdvanceShirt, o.AdvanceMed, o.AdvanceOther FROM $PAYROLL.other_deductions o, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $rsOtherDed = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['BurialSeparationCont'] = $BurialSep; $saverec['TaxAjt'] = $TaxAjt; $saverec['CashAdvance'] = $CashAdvance; $saverec['AdvanceShirt'] = $AdvancesShirt; $saverec['AdvanceMed'] = $AdvancesMed; $saverec['AdvanceOther'] = $AdvancesOthers; $insert = $conn2->GetInsertSQL($rsOtherDed, $saverec); $conn2->Execute($insert); } $Amount = $_POST["Amount"]; $TotEarn = $_POST["TotEarn"]; $TotalDed = $_POST["TotalDed"]; $THP = $_POST["TakeHomePay"]; $sql = "SELECT EMP_NO, Amount, TotalEarnings, TotalDeductions, TakeHomePay FROM totalpay WHERE EMP_NO = '$empno'"; $rsTotal = $conn2->Execute($sql); $numrows = $rsTotal->RecordCount(); if($numrows > 0){ $saverec['EMP_NO'] = $empno; $saverec['Amount'] = $Amount; $saverec['TotalEarnings'] = $TotEarn; $saverec['TotalDeductions'] = $TotalDed; $saverec['TakeHomePay'] = $THP; $updateSQL = $conn2->GetUpdateSQL($rsTotal, $saverec); $conn2->Execute($updateSQL); } else{ $sql = "SELECT t.EMP_NO, t.Amount, t.TotalEarnings, t.TotalDeductions, t.TakeHomePay FROM $PAYROLL.totalpay t, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; $rsTotal = $conn2->Execute($sql); $saverec['EMP_NO'] = $empno; $saverec['Amount'] = $Amount; $saverec['TotalEarnings'] = $TotEarn; $saverec['TotalDeductions'] = $TotalDed; $saverec['TakeHomePay'] = $THP; $insertSQL = $conn2->GetInsertSQL($rsTotal, $saverec); $conn2->Execute($insertSQL); } I don't know where I can put this code to save the data that i inserted in other deductions Hi, i have a transaction table which includes following fields. tran_ID,account_number,account_type,transaction_type,amount,Date I want to know how these data can be retrieved and display in another table. The table is filled with several records. Thanks, Heshan I have a simple query and need to print the result. My code does not print a resulr but the query is valid and returns a result. Any help appreciated. Code: [Select] $query = ("SELECT * FROM wp_book WHERE Author_ID = '$Author_ID'"); $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) { echo "<br />"; echo"No Result"; } echo"Result"; while($row = mysql_fetch_assoc($result)){ echo $row['WorkingTitle']; } So when I load my paginator it returns No Results Found. 1) My query is only returning 1 array entry, should be hundreds, maybe I'm not builing it correctly, 2) There is at least 1 array set but its still saying data not found. Heres the template array: Code: [Select] array('id'=>'0', 'name'=>'xmlqoyzgmykrphvyiz', 'date'=>'13-Sep-2002', 'price'=>'8370', 'number'=>'8056', 'address'=>'qdfbc', 'company'=>'taufrid', 'desc'=>'pppzhfhcdqcvbirw', 'age'=>'5512', 'title'=>'zticbcd', 'phone'=>'hvdkltabshgakjqmfrvxo', 'email'=>'eodnqepua', 'zip'=>'eodnqepua', 'country'=>'pdibxicpqipbsgnxyjumsza'), array('id'=>'1', 'name'=>'rbdmbabficcre', 'date'=>'10-Sep-2004', 'price'=>'3075', 'number'=>'3627', 'address'=>'oxcm', 'company'=>'xyzwzv', 'desc'=>'rwndyoedxh', 'age'=>'2134', 'title'=>'lxxyfgdtdffjce', 'phone'=>'zeejvbwy', 'email'=>'ldcikhxwfuulaxeedkogpxftb', 'zip'=>'ldcikhxwfuulaxeedkogpxftb', 'country'=>'pcmobxrdfclcyrx'), array('id'=>'2', 'name'=>'yr', 'date'=>'04-Mar-2007', 'price'=>'7129', 'number'=>'6614', 'address'=>'i', 'company'=>'gcpvrshftfxxlz', 'desc'=>'nyalrdjjl', 'age'=>'4728', 'title'=>'ddfl', 'phone'=>'mnhifzqltvirgiaug', 'email'=>'f', 'zip'=>'f', 'country'=>'epipbmtfsfxetenyedjxzsog'), etc Here is my arry: Code: [Select] $echoarray = array(); $resultsql = mysql_query("SELECT * FROM clients")or die(mysql_error()); while($row = mysql_fetch_array($resultsql)){ $echoarray['id'] = $row['ID']; $echoarray['name'] = $row['First_Name'] . " " . $row['Last_Name']; $echoarray['price'] = $row['Status']; $echoarray['number'] = $row['Sex']; $echoarray['address'] = $row['Phys_Street']; $echoarray['company'] = $row['Agency']; $echoarray['desc'] = $row['Notes']; $echoarray['age'] = $row['Date_Birth']; $echoarray['title'] = $row['Occupation']; $echoarray['phone'] = $row['Phone']; $echoarray['email'] = $row['Email']; $echoarray['zip'] = $row['Phys_Zip']; $echoarray['country'] = $row['Phys_City']; } Here is the template return: Code: [Select] function initArray() { return array( array('id'=>'0', 'name'=>'xmlqoyzgmykrphvyiz', 'date'=>'13-Sep-2002', 'price'=>'8370', 'number'=>'8056', 'address'=>'qdfbc', 'company'=>'taufrid', 'desc'=>'pppzhfhcdqcvbirw', 'age'=>'5512', 'title'=>'zticbcd', 'phone'=>'hvdkltabshgakjqmfrvxo', 'email'=>'eodnqepua', 'zip'=>'eodnqepua', 'country'=>'pdibxicpqipbsgnxyjumsza'), array('id'=>'1', 'name'=>'rbdmbabficcre', 'date'=>'10-Sep-2004', 'price'=>'3075', 'number'=>'3627', 'address'=>'oxcm', 'company'=>'xyzwzv', 'desc'=>'rwndyoedxh', 'age'=>'2134', 'title'=>'lxxyfgdtdffjce', 'phone'=>'zeejvbwy', 'email'=>'ldcikhxwfuulaxeedkogpxftb', 'zip'=>'ldcikhxwfuulaxeedkogpxftb', 'country'=>'pcmobxrdfclcyrx'), array('id'=>'2', 'name'=>'yr', 'date'=>'04-Mar-2007', 'price'=>'7129', 'number'=>'6614', 'address'=>'i', 'company'=>'gcpvrshftfxxlz', 'desc'=>'nyalrdjjl', 'age'=>'4728', 'title'=>'ddfl', 'phone'=>'mnhifzqltvirgiaug', 'email'=>'f', 'zip'=>'f', 'country'=>'epipbmtfsfxetenyedjxzsog'), array('id'=>'3', 'name'=>'bhqggvwolybfdtk', 'date'=>'26-Dec-2000', 'price'=>'1867', 'number'=>'4288', 'address'=>'jo', 'company'=>'goevufkvmbct', 'desc'=>'zhixinabyazbfleozrvovr', 'age'=>'3423', 'title'=>'b', 'phone'=>'odhh', 'email'=>'g', 'zip'=>'g', 'country'=>'idxvdztezvkkaz')); } And Mine: Code: [Select] function initArray() { return $echoarray; } Where am I going wrong here? Hi all, this is the code i'm using at the moment which is at the bottom of a webpage Code: [Select] // Open file export.csv. $f = fopen("export.csv", "w"); // Put all values from $out to export.csv. fputs($f, $out); fclose($f); $filename = "StatisticalAnalysis-" . gmdate("Y-m-d-H-i-s") . ".csv"; header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=" . $filename); readfile("export.csv"); The variable named $out is a long line of text in csv format. I've echoed that variable and it's all good. When a checkbox in a form further up the page is checked the code creates and fills in the $out variable and then carries out the code above. The problem i have is that when the csv save dialog comes up and the file is saved, all it contains is a copy of the html code which is on that page, not the info stored in the $out variable. Can anyone offer any advice on what the problem is? Cheers This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=309496.0 |