PHP - Not Saving To Table
Am trying to update a table called "budget_request" and also inserting the data of that table into another table called "Budget". The Update works but it is not inserting into the other table. please help me out.. check my code below
<?php
$id = $_GET['id']; ?> <?php include('mysql_connect.php'); $q = mysql_query("UPDATE budget_request SET status = 'Approved' WHERE id = '$id'") or die(mysql_error()); // send the details to the budget database $query = mysql_query("SELECT * FROM budget_request WHERE id = '$id' ") or die (mysql_error()); $dat = mysql_fetch_array($query); $department = $dat['department']; $amount = $dat['amount']; // Add the data to the Budget DB $que = (" INSERT INTO budget (id, department, amount, actual) VALUES ( ' ','$department', '$amount', '$amount')" ) or die(mysql_error()); header("Location: add_budget.php"); ?> Similar TutorialsI have problem how to saving all my record.
when I save I just got 1 record saved in mySQL and it the last record on that table. Here is my code =
<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO thasil (nrp, nama, pangkat, mgolongan, mtes_fisik, mkemampuan, hasil) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['nrp'], "int"), GetSQLValueString($_POST['nama'], "text"), GetSQLValueString($_POST['pangkat'], "text"), GetSQLValueString($_POST['mgolongan'], "int"), GetSQLValueString($_POST['mtes_fisik'], "double"), GetSQLValueString($_POST['mkemampuan'], "double"), GetSQLValueString($_POST['hasil'], "double")); mysql_select_db($database_stok, $stok); $Result1 = mysql_query($insertSQL, $stok) or die(mysql_error()); $insertGoTo = ""; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_stok, $stok); $query_anggotaset = "SELECT * FROM tanggota ORDER BY nrp ASC"; $anggotaset = mysql_query($query_anggotaset, $stok) or die(mysql_error()); $row_anggotaset = mysql_fetch_assoc($anggotaset); $totalRows_anggotaset = mysql_num_rows($anggotaset); mysql_select_db($database_stok, $stok); $query_bobotset = "SELECT * FROM tbobot"; $bobotset = mysql_query($query_bobotset, $stok) or die(mysql_error()); $row_bobotset = mysql_fetch_assoc($bobotset); $totalRows_bobotset = mysql_num_rows($bobotset); $crMax = mysql_query("SELECT min(Golongan) as minK1, max(tes_fisik) as maxK2, max(kemampuan) as maxK3 FROM tanggota"); $max = mysql_fetch_array($crMax); $no=1; ?> <?php include ('header.php') ?> <div id="conten-wrapper"> <div id="conten"> <h1> Normalisasi Anggota Kesamaptaan </h1> <p> <a href="cetak.php"><img src="../images/btn_list.png" height="20"/> >>> Lihat & Cetak Hasil Akhir Perangkingan</a></p> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table border="1" cellpadding="3" cellspacing="1"> <tr> <td>no</td> <td>nrp</td> <td>nama</td> <td>pangkat</td> <td>C1 Golongan</td> <td>C2 tes_fisik</td> <td>C3 kemampuan</td> <td>hasil</td> </tr> <?php do { $hasil= round (($max['minK1']/$row_anggotaset['Golongan']*$row_bobotset['golongan']+ $row_anggotaset['tes_fisik']/$max['maxK2']*$row_bobotset['tes_fisik']+ $row_anggotaset['kemampuan']/$max['maxK3']*$row_bobotset['kemampuan']),2) ; ?> <tr> <td><?php echo $no; $no++;?></td> <td><input type="text" name="nrp" value="<?php echo $row_anggotaset['nrp']; ?>" readonly/></td> <td><input type="text" name="nama" value="<?php echo $row_anggotaset['nama']; ?>" readonly/></td> <td><input type="text" name="pangkat" value="<?php echo $row_anggotaset['pangkat']; ?>" size="4" readonly/></td> <td><input type="text" name="mgolongan" value="<?php echo round ($max['minK1']/$row_anggotaset['Golongan'] *$row_bobotset['golongan'],2); ?>" size="2" readonly/></td> <td><input type="text" name="mtes_fisik" value="<?php echo round ($row_anggotaset['tes_fisik']/$max['maxK2'] *$row_bobotset['tes_fisik'],2); ?>" size="2" readonly/></td> <td><input type="text" name="mkemampuan" value="<?php echo round ($row_anggotaset['kemampuan']/$max['maxK3'] *$row_bobotset['kemampuan'],2); ?>" size="3" readonly/></td> <td><input type="text" name="hasil" value="<?php echo $hasil ?>" size="2" readonly/></td> </tr> <?php } while ($row_anggotaset = mysql_fetch_assoc($anggotaset));?> <tr valign="baseline"> <td colspan="8" align="right" nowrap="nowrap"><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> </div> <?php include ('footer.php') ?> </body> </html> <?php mysql_free_result($anggotaset); mysql_free_result($bobotset); ?> Hey guys, I need your help on this please. I am working on a php web application. I have a form that gets information for Supplier and his traveling details. The values are stored in arrays. I would like to store supplier details in Supplier table and the travelling details in the Travel table. Here is the code with the comments. <?php if (isset($_VARS['submitSuppliers'])) { //error checking starts here $isError = false; if (empty($_VARS['supplierName'])) { $isError = true; $_VARS['supplierRequest']['supplierName']['errorMessage'] = 'You need to provide a Supplier Name.'; } if (empty($_VARS['address'])) { $isError = true; $_VARS['supplierRequest']['address']['errorMessage'] = 'You need to provide an Address.'; } if (empty($_VARS['travel'])) { $isError = true; $_VARS['supplierRequest']['city']['errorMessage'] = 'You need to provide travelling details.'; } #this checks if there is no error and then proceeds to save form values if (!$isError) { #This function adds the details and Returns the autoincremented Supplier ID $SupId = add_suppliers($_VARS); if ($SupId) { #=== Now here I would like to save the travelling details in the Travel table using the generated supplier id # $travId = add_Travel($_VARS); //==== how do I segregate only travel details from the $_VARS array to store in travel table? REDIRECT('/supplier/index.html', array('confirmationMessage' => 'Your details have been saved.')); }else { notify_admin('supplierjoin.php'); } }else { $_VARS['supplierRequest']['errorMessage'] = "There was a problem with the information you provided. Please check the form and try again."; } } ?> Kindly help. Any comment or feedback is always welcome. Thank you Hello
Is it possible to save data from saved htm table from other website in our mysql database system
as I have problem that there is one htm page where i can get data but i want to save it in mysql table. as data is large on htm page
it was hard to copy so i want access it direct from php and save it in mysql table
please guide
awaiting your valuable reply.
Thank in advance
i have made 2 classes. the first "point" has an array of 3 floats and some functions to help manipulate the values the second "triangle" has an array of 3 points. in this way if i want to make a tetrahedron i can make 4 points and assign them to 4 triangles. problem is for some reason each triangle point group seems to use 1k. any idea why? I have a .php code that gets data from a database and saves it in a variables as xml. However how can I then save all of the data in this variable as a .xml file somewhere? Thanks for any help. Hi I'm really new to php and could really do with some help. I am using the following script http://test.dpetroff.ru/jquery.iviewer.test/test/ which basically allows me to position an image within a DIV area My question is, how can I get PHP to save just the image within the DIV area, so it's almost acting like a crop tool I've tried a few things but so far not managed to get anything working Hi, I'm completely new to anything that is not html but I'm wondering if in something like php I can get a checkbox to permanently save through reloads and different machines. My idea was just to have a page with only a checkbox on it, and then load that through and iframe in html. If anybody could give me the code for that checkbox page (complete if possible as I don't really know anything about that type of programming) I would be very grateful. Thank You $new_relation->save(); echo "after save".$requestor_profile->getId()." ".$requestee_profile->getId(); return true; }catch(PropelException $e) { echo "in die"; die($e); return false; } }//end - if (!$res) [/PHP] the echo after the save executes but when i look in my db table there is nothing???? please help??? I'm trying to get an equation from a user that types it in the url, ex) 1+2+3. I can get the 1,2,3 fine, but the + operator is no longer in the string. Same with the * and / operators. Is there a way to keep them as a string using $_GET?
Hi All... I am looking for a way of saving currently open webpage as a pdf file.........I searched for that and even gone for this site http://www.tcpdf.org. But there also I didn't find any perfect way of doing this all....If somebody else has tried tcpdf for that or done something like that, then plzzzzz plzzz plzzzz do help me....Thanx...... Hi guys, Right now, I just save / update the database and refresh the page. I'd like to do all of that, but have a nice looking 'Save / Update' indication - indicator. How do you guys do it? Do you have any recommendations? Thanks Hi Guys, Using this code i am able to overlay a logo onto an image: <?php // Load the image where the logo will be embeded into $image = imagecreatefromjpeg("box.jpg"); // Load the logo image $logoImage = imagecreatefrompng("logo.png"); imagealphablending($logoImage, true); // Get dimensions $imageWidth=imagesx($image); $imageHeight=imagesy($image); $logoWidth=imagesx($logoImage); $logoHeight=imagesy($logoImage); // Paste the logo imagecopy( // source $image, // destination $logoImage, // destination x and y $imageWidth-$logoWidth, $imageHeight-$logoHeight, // source x and y 0, 0, // width and height of the area of the source to copy $logoWidth, $logoHeight); // Set type of image and send the output //header("Content-type: image/png"); //imagePng($image); imagejpeg($logoImage, "imageWithLogo.jpg", 100); // Release memory imageDestroy($image); imageDestroy($imageLogo); ?> this part: //header("Content-type: image/png"); //imagePng($image); shows me the complete image with the logo ontop, what i'm having trouble with is saving the image. any help would be appreciated thanks guys Graham I am using the scripts (at the end) on a shared debian server at my web host's remote facility. Hi guys Im looking to save the contents of 4 textboxes to a mySql db. Using wamp, phpmyadmin etc. Code: [Select] ?php $Name = $_Post('Name'); $Age = $_Post('Age'); $Sex = $_Post('Sex'); $Address_1 = $_Post('Address_1'); mysql_connect("127.0.0.1","user","") or die ('Error: ' .mysql_error()); mysql_select_db("user"); $query ="INSERT INTO users(Name,Age,Sex,Address_1) VALUES('".$Name."', '".$Age."','".$Sex."','".$Address_1."'); mysql_query($query) or die ('Error updating datadase'); mysql_Close(); ?>This is the code im using, it dosent seem to do anything to the database..... can someone point out where im going wrong... thanks Hi, I'm still new to php and having some problems. Sorry about the code not being formatted properly. The snippet I posted has both the code intend to work but it is commented out and a test version that has an array already set thus getting rid of the need of setting up every thing like I have. Ok this is basically my problem. I'm building a store like website. Its suppose to be very basic for now Part of the website is an RMA system where the customer enters an order number and then pulls up all items in the order on a different page in a table format with check boxes next to each item found in the database. Each item that is checked off is then saved to an array rma[] which posts to another page when submitted. What this page(copied down below) does is it pulls values from the cookie already made and creates new variables which is not a problem. After that it does a foreach loop for the array of the items into a mysql query which then is suppose to insert it into a database. When the code runs it only inserts the first item in the array into the database no matter how many items are in the array. When I echo the $insert statement I get this(using the test code) like I expect I'm suppose to. I would assume that because I'm doing a foreach loop that it is doing an INSERT for the number of items in the array. Quote INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('857442', '1','Saab','123') INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('857442', '1','Volvo','123') INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('857442', '1','BMW','123') INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('857442', '1','Toyota','123') Code: [Select] <?php //connects to the data base mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("project") or die(mysql_error()); /* //retrieving rma array from previous page $rmarequest = $_POST['rma']; //retieves using name from cookie $username = $_COOKIE['ID_my_site']; //retrieves order number from cookie $ordernumber = $_COOKIE['order']; //creates rma number $rmanumber = rand(1000, 999999); //retrieves accountid from database using the username $getid = mysql_query("SELECT AccountID FROM users WHERE username = '$username'"); $id = mysql_fetch_array( $getid ); //takes the value of $id $final = $id['AccountID']; //suppose to loop through all values for the array created by $request on the previous page and insert into database foreach($rmarequest as $key){ // $insert = "INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('".$rmanumber."', '".$AccountID."','".$key."','".$ordernumber."')"; //mysql_query($insert) OR die(mysql_error()); //this is test to see what is being passed to mysql server $insert = "INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('".$rmanumber."', '1','".$key."','123')"; //mysql_query($insert) OR die(mysql_error()); //to view what $insert is passing to the data base. echo $insert;} */ //THIS SECTION IS TEST ONLY //test array $cars[0]="Saab"; $rmarequest[1]="Volvo"; $rmarequest[2]="BMW"; $rmarequest[3]="Toyota"; //creates rma number $rmanumber = rand(1000, 999999); foreach($rmarequest as $key){ //this is test to see what is being passed to mysql server $insert = "INSERT INTO `project`.`rma` (rmanumber, AccountID, item, ordernumber) VALUES ('".$rmanumber."', '1','".$key."','123')"; mysql_query($insert) OR die(mysql_error()); //to view what $insert is passing to the data base. echo $insert."<br />"; } ?> Included is a copy of the table and the php code above. I have a bunch of users in a database (id, name, etc).
I have a bunch of documents which belong to users (id, filename, users_id, etc), and expect 500 or less per user.
The documents will be renamed to the document_id, and X-Sendfile (since they are stored under the document root) will be used to retrieve them and a header will be used to return them to their original name.
Is it recommended to make a separate folder for each user and store each individual user's documents in that folder, or create one folder for all documents?
If I go with the one folder approach, I will need some method from keeping the total files per folder below some reasonable limit (1,000?). My thought is to estimate the maximum potential number of folders, and creating subfolders under the main document folder. I will likely hash the ID, and use the first character to create the first subfolder, the second character to create a second subfolder in the first subfolder, and continue as long as needed to accommodate the maximum potential documents (if there are 1,000,000 potential folders, then three levels will keep the maximum per folder under 244).
Please provide rational for one approach over the other.
Thank you
$name = mysqli_real_escape_string($link, $_POST['name']); $adjective = mysqli_real_escape_string($link, $_POST['adjective']); $verb = mysqli_real_escape_string($link, $_POST['verb']); $noun = mysqli_real_escape_string($link, $_POST['noun']); $sql = "INSERT INTO mad (name, adjective, verb, noun) VALUES ('$name', '$adjective', '$verb', '$noun')"; if(mysqli_query($link, $sql)){ echo "Records added successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } $name= ucwords($name); $title="The Life of $name"; echo "<title>$title</title>"; ?> <style type="text/css"> form {text-align: right;} .madlibbox { background: #F2F1E9; border-right: #25201A 1px solid; border-top: #25201A 1px solid; border-left: #25201A 1px solid; border-bottom: #25201A 1px solid; padding: 10px 10px 10px 10px; font-size: medium; margin: auto; width: 340px; font-family: Verdana, "Myriad Web", Syntax, sans-serif; } body { padding: 0; border: 0; background: #DFDFC8; width: auto; text-align: center; } h1 {padding: 10px; text-align: center; text-transform: uppercase;} </style> </head> <body> <div class = "content"> <?php echo "<h1>$title</h1>"; ?> <div class = "madlibbox"> <?php echo "There once was a named $name who lived in $noun and liked to $verb and talk to the neighbor's $adjective. This bothered $name's best friend drew. The end."; ?> </div> </div></body></html> I am new to programming and I have no clue on how to do the following. I want to be able to save the output of the story to a sql database. Once it is display, have them click on a link to have previous save stories to be displayed randomly or have it generate a random story based on previous save inputs to the database. This code works to display the story and save the variables inputs.
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 Guys, I'm pulling a html page from a database (html newsletter). In the code I have links that will open a lightbox and allow the user to add news articles into it via ajax. So the html is being updated without being send back to the browser. I have a "save" button which when the user clicks, I want to grab all of the html of the page and save it to the database. Not quite sure how to do this as the html that is being saved, is updated since it was retrieved by the browser. Friends, Requirement: I want to Extract the Keywords from All the Search Engine Referer URLs and save all the keywords in an Array so i can Echo/show all the "popular Terms" which drive traffic to my Site from Search Engines. I already have the Code for Extracting the Keyword from URL, can someone tell me how can i save the $keyword in an array that whenever i visit my site, i can see that What all keywords brought visitors to my site from Search Engines? Code to Extract Keywords from URL: <? $referrer = $_SERVER['HTTP_REFERER']; $referrer ='http://www.google.co.id/search?hl=id&client=firefox-a&hs=IKn&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&q=pemahaman+pelajaran+ips+tentang+endogen+dan+eksogen&aq=f&aqi=&aql=&oq=&gs_rfai='; $referrer_query = parse_url($referrer); $referrer_host = $referrer_query['host']; $referrer_query = $referrer_query['query']; $q = "[q|p|qkw|key|query|searchfor|Keywords|searchterm]"; //Yahoo uses both query strings, I am using switch() for each search engine preg_match('/'.$q.'=(.*?)&/',$referrer,$keyword); $keyword = urldecode($keyword[1]); $potongnya = array('&q=','&p=','key=','query=','searchfor=','Keywords=','searchterm='); $referrer_query = str_replace($potongnya, "&|pencarian=", $referrer_query); $arr = explode("&", "$referrer_query"); for($k = 0, $l = count($arr); $k < $l; ++$k) { $ygdicari = "$arr[$k]"; $findmeyach = "|pencarian="; $posnyaaa = strpos($ygdicari, $findmeyach); if ($posnyaaa === false) {} else { $keyword = str_replace('|pencarian=', "", $ygdicari); $potongkeynya = array('+','%20'); $keyword = str_replace($potongkeynya, " ", $keyword); } } if ($keyword=="") { $potongnya = array('q=','p='); $referrer_query = str_replace($potongnya, "&|pencarian=", $referrer_query); $arr = explode("&", "$referrer_query"); for($k = 0, $l = count($arr); $k < $l; ++$k) { $ygdicari = "$arr[$k]"; $findmeyach = "|pencarian="; $posnyaaa = strpos($ygdicari, $findmeyach); if ($posnyaaa === false) {} else { $keyword = str_replace('|pencarian=', "", $ygdicari); $potongkeynya = array('+','%20'); $keyword = str_replace($potongkeynya, " ", $keyword); } } } $keyword = strtolower($keyword); $urikeyword = array('sex ','porn ','porno',', ','penis ','penis ','http://www.','http://','http','gamble','"',"'"); $keyword = str_replace($urikeyword, "", "$keyword"); echo "$keyword"; exit; ?> Many Thanks Natasha T |