Jump to content

Slowie

Members
  • Posts

    52
  • Joined

  • Last visited

    Never

Everything posted by Slowie

  1. Ive sorted this problem mind lock released this morning now i have an issue of i currently have and array what looks like this when output Array ( [0] => Array ( [start] => 58 ) [1] => Array ( [start] => 58 ) [2] => Array ( [start] => 57 ) [3] => Array ( [start] => 57 ) ) how would I now using php add the values from this array using only the previous and previous previous keys e.g 0 result would be 0 1 would be 58 2 would be 116 3 would be 173 and so on for a dynamic array thanks in advance
  2. Thank you however i changed my code overnight and now its more like this... i need it to divide up 800 into equal or near equal arrays. array(800 values) minarraysize = user submitted max array size = minarraysize+(minarraysize-1) remainder_after_division = count(array) % minarraysize ; arrays to split into = array / min array size if ((remainder_after_division < minarraysize ) || (remainder_after_division != 0)){ its here where i get stuck as if the arrays to split into is 25 i need it to cycle through 26 arrays adding 1 each time untill all of the values have been used so itd look like => Array ( [start] => 0 [split] => 36 ) [1] => Array ( [start] => 36 [split] => 36 ) [2] => Array ( [start] => 72 [split] => 35 ) [3] => Array ( [start] => 107 [split] => 35 ) }
  3. hey guys just a quick onei having a blank moment i have an array at themoment pulling from a database. i basically want to split this array based on a min and max value. divide it equally and then give it a value on each smaller array and where each array starts... to make it clearer - say i have an array with 600 values in i want it split up into 8 smaller arrays link so Array ( [0] => Array ( [start] => 0 [split] => 75 ) [1] => Array ( [start] => 75 [split] => 75 ) [2] => Array ( [start] => 150 [split] => 75 ) carrying on till the end ) how would i do this.
  4. i solved it in the end the query i was looking for was as below. but thank you for the help everyone SELECT options.optionsid, userlevel.Description, branch.branch, COUNT(*) AS Staff, stafflist.user_level FROM stafflist Left Join userlevel on stafflist.user_level=userlevel.level Left Join branch On stafflist.branch=branch.branchid Left Join options On userlevel.level=options.user_level Where options.branch=stafflist.branch GROUP BY branch, user_level
  5. currently with $sql = "select options.company, options.user_level, options.branch, userlevel.Description, branch.branch as branch from options left join branch on options.branch=branch.branchid left join userlevel on options.user_level=userlevel.level where options.user_level != '0' And options.user_level != '2' And options.user_level != '4' AND options.company='".$_SESSION['company']."' " ; i get the branch along with the userlevel so that is 1 - 1 1 - 2 1 - 3 2 - 1 2 - 2 2 - 3 now i know i need to left join in the stafflist table and do a count similar to this one SELECT branch, user_level, COUNT(*) AS staff FROM stafflist GROUP BY branch, user_level this gives me the results i want but i need this in one mysql query for a table i just cant work out how to do it
  6. nope this is way out haha just been messing around with it again. i cant get this right
  7. ok so going on that my current code is select options.company, options.user_level, options.branch, userlevel.Description, branch.branch as branch from options left join branch on options.branch=branch.branchid left join userlevel on options.user_level=userlevel.level where options.user_level != '0' And options.user_level != '2' And options.user_level != '4' AND options.company='".$_SESSION['company']."' so the code after the changes will be SELECT options.company, options.user_level, options.branch, Count(stafflist.userlevel) AS userlevel userlevel.Description, branch.branch AS branch FROM options LEFT JOIN branch on options.branch=branch.branchid LEFT JOIN userlevel on options.user_level=userlevel.level LEFT JOIN stafflist on stafflist.branch=options.branch WHERE options.user_level != '0' AND options.user_level != '2' AND options.user_level != '4' AND options.company='".$_SESSION['company']."' GROUP BY options.branch, stafflist.userlevel would this be correct?
  8. can no one give me a little advice on this?
  9. hey guys ive been trying to do this one all night and i dont know if im either approching it wrong or its just not possible. i have tried multiple ways of doing it but havent succeded. basically i have 2 tables one called user level and one called stafflist now in the user level table i have 2 companies with 3 userlevels for each so company userlevel 1 1 1 2 1 3 2 1 2 2 2 3 now in the stafflist table there are lets say 40 staff members and each have a field filled in which is the company with either 1 or 2 they also each have a user level assigned. so 1 , 2 or 3 what i want is for the query to count how many staff are assigned each level for that company so the end result is a table like company userlevel number of staff 1 1 15 1 2 3 1 3 2 2 1 18 2 2 2 2 3 0 could someone explain how i would go about this. ill figure out the exact code but i just need a shove in the right direction
  10. im working on that atm but for a quick setup i needed to do this as multiple branches and branch setup wernt asked of originally. my plan for the future is to use a single header file. this was the only copy needed in the future is the css file as each branch will have different colours. thank you for the advice though it is much appreciated
  11. ive made a website where the user might want to add a branch. the website has a login and each user has a branch id associated with it. when they log in it loads a specific css file and header file. what ive done is when the admin user wants to add a new brnch i didnt want a phone call saying could you add it in so ive made a page where they enter the branch name and select a colour then upload a banner and the page created everything like the header file the css file and the images for that branch. it means little interaction from the user and little chance for me to miss something.
  12. i could kick myself for this but its my error because i was referencing a file what wasnt in that directory. spotted it this morning after i had a few pints last night and a sleep. it now works thank you so much
  13. ah thank you ive tried this and yet still im getting the error my code is <?php $banner = "/images/" . $name . "/Banner.png"; $template = fopen("../Header/Template.php", "r"); // with the appropriate checks of course $data = str_replace( '/*-headerbanner-*/', $banner, $template); //etc, str_replace your vars $handle = fopen("../Header/" . $name . ".php", 'w'); // with the appropriate checks of course fwrite($handle, $data); // with the appropriate checks of course print "Data Written"; fclose($handle); ?>
  14. ive just noticed that if i add another branch then it dupicates my data onto however many tables e.g. table1 table 2 table 3 if i add 2 more branches what would cause this?
  15. on your advice i did this $banner = "/images/" . $name . "/Banner.png"; $data = fopen("../Header/Template.php", "r"); // with the appropriate checks of course str_replace( '/*-headerbanner-*/', $banner, $data); //etc, str_replace your vars $handle = fopen("../Header/" . $name . ".php", 'w'); // with the appropriate checks of course fwrite($handle, $data); // with the appropriate checks of course print "Data Written"; fclose($handle); however the file generated only has "Resource id #12" inside. whats happening with it?
  16. ok ive made this work in one way by having it include the php file instead but how would i edit the data in the newly created file? $header = include("../Header/headerj.php"); $dir = "../Header/"; $file = "" . $name . ".php"; $dir = "$dir"."$file"; touch($dir); $Handle = fopen($dir, 'w'); $Data = "" . $header . ""; fwrite($Handle, $Data); print "Data Written"; fclose($Handle); if i include this file and change some of the things in the original php file whats being included to variables would it pull the variables from the current php file?
  17. hey guys its me again. what i want is for me to be able to edit php using variables and post it as a new file. now to attchieve this i am simply copying the current template into the php file and telling it to grap what variables it needs. i have successfully done this with a .css file but when im doing it with a php file its erroring at <?php as the file is already in php. what i need to know is can i have the php file look at the <?php as just text to write to a file? my code is below $dir = "../Header/"; $file = "" . $branchid . ".php"; $dir = "$dir"."$file"; touch($dir); $Handle = fopen($dir, 'w'); $Data = " <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php //We count the number of new messages the user has $nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['user_id'].'" and user1read="no") or (user2="'.$_SESSION['user_id'].'" and user2read="no")) and id2="1"')); //The number of new messages is in the variable $nb_new_pm $nb_new_pm = $nb_new_pm['nb_new_pm']; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <style type="text/css"> /* Remove margins from the 'html' and 'body' tags, and ensure the page takes up full screen height */ html, body { margin:0; padding:0;} /* Set the position and dimensions of the background image. */ #page-background {position:fixed; top:0; left:0; width:100%; height:100%;} /* Specify the position and layering for the content that needs to appear in front of the background image. Must have a higher z-index value than the background image. Also add some padding to compensate for removing the margin from the 'html' and 'body' tags. */ #content {position:relative; z-index:1; padding:10px;} </style> <head> <title>Apollo - Data Management System</title> <!--Links--> <link rel="icon" type="image/ico" href="favicon.ico"></link> <link rel="stylesheet" media="all" type="text/css" href="/styles.css" /> </head> <body> <div id="Headerlogo"> <img src="/images/PaulKemp/PaulBanner.png" width="100%" alt="Smile"></div> <div class="wrapper1"> <div class="wrapper"> <div class="nav-wrapper"> <div class="nav"> <ul id="navigation"> <li class="active"> <a href="/Main/myaccount.php"> <span class="menu-left"></span> <span class="menu-mid">Main Menu</span> <span class="menu-right"></span> </a> </li> <li class=""> <a href="/PersonnelMessages/list_pm.php"> <span class="menu-left"></span> <span class="menu-mid"><b>Messages(<?php echo $nb_new_pm; ?> unread)</b></span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/PersonnelMessages/new_pm.php">New Personal Message</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <?php if (checkMasterAdmin()) { ?> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Admin</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Admin/UploadServices.php">New KPI</a> </li> <li> <a href="/Admin/MonthReview.php">New Month Review</a> </li> <li> <a href="/Admin/CreateUser.php">New User</a> </li> <li> <a href="/Admin/EditUsers.php">Edit User</a> </li> <li> <a href="/Admin/HolidayRequests.php">Authorise Holidays</a> </li> <li> <a href="/Backup/BackupSite.php">Backup</a> </li> <li> <a href="/PersonnelMessages/CompanyAnnouncement.php">Company Announcements</a> </li> <li> <a href="/PersonnelMessages/DeleteAnnouncements.php">Delete Announcements</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <?php } ?> <?php if (checkAdmin()) { ?> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Admin</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Admin/UploadServices.php">New KPI</a> </li> <li> <a href="/Admin//MonthReview.php">New Month Review</a> </li> <li> <a href="/Admin/CreateUser.php">New User</a> </li> <li> <a href="/Admin/EditUsers.php">Edit User</a> </li> <li> <a href="/Admin/HolidayRequests.php">Authorise Holidays</a> </li> <li> <a href="/Backup/BackupSite.php">Backup</a> </li> <li> <a href="/PersonnelMessages/CompanyAnnouncement.php">Company Announcements</a> </li> <li> <a href="/PersonnelMessages/DeleteAnnouncements.php">Delete Announcements</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <?php } ?> <?php if (checkBranchOwner()) { ?> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Admin</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Admin/UploadServices.php">New KPI</a> </li> <li> <a href="/Admin//MonthReview.php">New Month Review</a> </li> <li> <a href="/Admin/CreateUser.php">New User</a> </li> <li> <a href="/Admin/EditUsers.php">Edit User</a> </li> <li> <a href="/Admin/HolidayRequests.php">Authorise Holidays</a> </li> <li> <a href="/Backup/BackupSite.php">Backup</a> </li> <li> <a href="/PersonnelMessages/CompanyAnnouncement.php">Company Announcements</a> </li> <li> <a href="/PersonnelMessages/DeleteAnnouncements.php">Delete Announcements</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <?php } ?> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Staff</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Staff/ChangePassword.php">Change Password</a> </li> <li> <a href="/Staff/mysettings.php">Change Details</a> </li> <li> <a href="/Staff/HolidaysLeft.php">Holidays Left</a> </li> <li> <a href="/Staff/profile.php">My Profile</a> </li> <li> <a href="/Staff/MyServices.php">My Services</a> </li> <li> <a href="/Viewmonthreports.php">Month Review</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Referrers</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Referrers/Newreferrers.php">New Referrers</a> </li> <li> <a href="/Referrers/SendReferrers.php">Send Referrers</a> </li> </ul> <div class="btm-bg"></div> </div> </li> <li class=""> <a href="#"> <span class="menu-left"></span> <span class="menu-mid">Holidays</span> <span class="menu-right"></span> </a> <div class="sub"> <ul> <li> <a href="/Holidays/RequestHoliday.php">Book Off Holiday</a> </li> <?php if (checkAdmin()) { ?> <li> <a href="/Admin/HolidayAmendments.php">Amend Holidays</a> </li> <li> <a href="/Admin/CancelledHolidays.php">Show Cancelled Holidays</a> </li> </li> <li> <a href="/reports/holidayreports.php">holiday report</a> </li> <?php } ?> <?php if (checkMasterAdmin()) { ?> <li> <a href="/Admin/HolidayAmendments.php">Amend Holidays</a> </li> <li> <a href="/Admin/CancelledHolidays.php">Show Cancelled Holidays</a> </li> <li> <a href="/reports/holidayreports.php">holiday report</a> </li> <?php } ?> </ul> <div class="btm-bg"></div> </div> </li> <li class=""> <a href="/logout.php"> <span class="menu-left"></span> <span class="menu-mid">Logout</span> <span class="menu-right"></span> </a> </li> </ul> </div> </div> </div> </div> <br /> "; fwrite($Handle, $Data); $Data = "Bilbo Jones\n"; fwrite($Handle, $Data); print "Data Written"; fclose($Handle);
  18. thank you so much it worked like a dream.
  19. its not working but it is at the same time. its getting some random fields in this order is 2,2,P,P,2,2 when it should be getting the info from the branch table. my table looks like this branchid branch companybranch 1 test 1 2 test2 1 1 test3 2 and heres the code to my page now <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/Apollo/dbc.php"; include_once($path); page_protect(); company(); @extract($_GET); $staffid=$id; $companyid=$company; $sql="SELECT stafflist.id, stafflist.full_name, stafflist.branch, branch.branchid, branch.branch as branchname FROM stafflist left Join branch on stafflist.company=branch.companybranch WHERE id = '".$staffid."'"; $result=mysql_query($sql); $userbranch = mysql_fetch_array($result); $sql1="SELECT * FROM branch WHERE companybranch = '".$company."'"; $result1=mysql_query($sql1); while ($row = mysql_fetch_array($result1)){ $arrBranches = $row; //this is putting each row from database into array to use later } ?> <html> <head> <title>Book Off Holiday</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="/Holidays/php_calendar/scripts.js" type="text/javascript"></script> <?php Header1(); ?> </head> <body> <div class="content1"> <form name "searchform" action="/Admin/EditUsers.php" method="post"> <table width="950px" border="0" align="center" cellpadding="2" cellspacing="0"> <tr class="mytables"> <td width="4%" class="title_cell"><strong>ID</strong></td> <td width="4%" class="title_cell"> <strong>Access</strong></td> <td width="10%" class="title_cell"><strong>User Name</strong></div></td> <td width="24%" class="title_cell"><strong>Email</strong></td> <td width="10%" class="title_cell"><strong>Approval</strong></td> <td width="10%" class="title_cell"> <strong>Banned</strong></td> <td width="15%" class="title_cell"> </td> </tr> <tr> <td> </td> <td width="10%"> </td> <td width="17%"><div align="center"></div></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <?php while ($rrows = mysql_fetch_array($result)) {?> <tr> <td><input name="u[]" type="checkbox" value="<?php echo $rrows['id']; ?>" id="u[]"></td> <td><select id="userlevel" name="userlevel"> <option value="0">Choose one</option> <?php foreach ($arrBranches as $branch)//for each array in the array of branches { echo '<option value="' . $branch['branchid'] . '"'; if($userbranch['branch'] == $branch['branchid']) echo ' selected '; echo '>'; echo $branch['branchid']; echo '</option>'; } ?> </select></td> <td> <span id="accesslevel<?php echo $rrows['id']; ?>"> <?php if($rrows['user_level'] == 0) echo "Guest"; if($rrows['user_level'] == 1) echo "User"; if($rrows['user_level'] == 2) echo "Manager"; if($rrows['user_level'] == 3) echo "Area Manager"; if($rrows['user_level'] == 4) echo "Branch Owner"; if($rrows['user_level'] == 5) echo "Admin"; if($rrows['user_level'] == 10) echo "Master Admin"; ?> </span> </td> <td><?php echo $rrows['user_name'];?></div></td> <td><?php echo $rrows['user_email']; ?></td> <td> <span id="approve<?php echo $rrows['id']; ?>"> <?php if(!$rrows['approved']) { echo "Pending"; } else {echo "Active"; }?> </span> </td> <td><span id="ban<?php echo $rrows['id']; ?>"> <?php if(!$rrows['banned']) { echo "no"; } else {echo "yes"; }?> </span> </td> </tr> <?php } ?> </table> </form> </div> </body>
  20. thank you so much i will try this now
  21. im still having trouble could someone help please my code so far looks like this but its not working as i want $sql="SELECT stafflist.id, stafflist.full_name, stafflist.branch, branch.branchid, branch.branch as branchname FROM stafflist left Join branch on stafflist.company=branch.companybranch WHERE id = '".$staffid."'"; $result=mysql_query($sql); $sql1="SELECT * FROM branch WHERE companybranch = '".$company."'"; $result1=mysql_query($sql1); <select id="userlevel" name="userlevel"> <option value="0">Choose one</option> <? $userbranch = mysql_fetch_array($result); $branchid = mysql_fetch_array($result1); echo $userbranch; echo $branchid; foreach ($userbranch as $branchid) { echo '<option value="' . $branchid['branchid'] . '"'; if($userbranch['branch'] == $branchid['branchid']) echo ' selected '; echo '>'; echo $branchid['branch']; echo '</option>'; } ?> </select>
  22. hey guys just a quick one i want a drop down box which is populated from a mysql query which is eay enough but also at the same time i also want the dropdown box to look at the current record and have the value in the drop down box e.g. the drop down has values 1, 2, 3, 4, 5 in it which are pulled from a table called values the current record is from a table called staff and it has an id of 45 and a user level of 3 i want the drop down to have all the values selectable to update the record but on load it will have 3 as the current, i want to be able to chage this 3 to a 5 and update the record how can i do this.? just a brief code example would be awsome and ill adopt it to fit
  23. Can anyone help me ???? its really making me :'( now
  24. hey guys im really stuck and need help with this. im trying to update a mysql table from an array. basically i have 12 records what are pulled using a query. each record has its own ID to distinguish it from the rest. i then have 2 tick boxes for the user to select one for accept and one for deny. what i need is for the query to look at each record on the table and insert the selection boxes value if ticked. my code is below but i have altered it to the hilt and cannot get it to work so please help :D :D <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/Apollo/dbc.php"; include_once($path); $rs_results = mysql_query("SELECT * FROM off WHERE IsItAuthorised='0' and isitsick='0' ORDER BY DayOff"); ?> <html> <head> <title>Administration Main Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <?php if (isset($_POST['submit'])) { //Assign each array to a variable $id = $_POST['id']; $approve = $_POST['approve']; $deny = $_POST['deny']; $limit = count($id); $values = array(); // initialize an empty array to hold the values for($k=0;$k<$limit;$k++){ $msg[] = "$limit Holidays Updated"; $id[k] = $id; $approve[k] = $approve; $deny[k] = $deny; $id = implode($id); $approve = implode( $approve); $deny = implode( $deny); $query = "UPDATE off SET Authorised = $approve , Deny = $deny WHERE OffID = $id " ; } $Event = "INSERT INTO events (UserName, Event ) VALUES ('$_SESSION[user_name]', 'Entered New KPI' )"; echo $query; if (!mysql_query($query,$link)){ die('Error: ' . mysql_error()); } else { mysql_query($Event); echo "<div class=\"msg\">" . $msg[0] . "</div>"; } } ?> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="14%" valign="top"><?php ?> </td> <td width="74%" valign="top" style="padding: 10px;"> <p><?php if(!empty($msg)) { echo $msg[0]; } ?></p> <p> <?php $cond = ''; $sql = "select * from off "; $rs_total = mysql_query($sql) or die(mysql_error()); $total = mysql_num_rows($rs_total); ?> <p> <form name "searchform" action="/Apollo/Admin/HolidayRequests.php" method="post"> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr class="mytables"> <td width="4%"><font color="white"><strong>ID</font></strong></td> <td width="4%"> <font color="white"><strong>Staff Member</font></strong></td> <td width="10%"><font color="white"><strong>Day Off</font></strong></div></td> <td width="10%"><font color="white"><strong>Is It Authorized</font></strong></div></td> <td width="15%"> </td> </tr> <tr> <td> </td> <td width="10%"> </td> <td width="17%"><div align="center"></div></td> <td> </td> </tr> <?php while ($rrows = mysql_fetch_array($rs_results)) {?> <tr> <td><input name="id[]" id="id[]" size="4" value="<?php echo $rrows['OffID'];?>" /></td> <td><?php echo $rrows['StaffMember']; ?></td> <td><?php echo date('d/m/Y', strtotime($rrows['DayOff']));?></div></td> <td> <span id="approve<?php echo $rrows['id']; ?>"> <?php if(!$rrows['IsItAuthorised']) { echo "Pending"; } else {echo "Authorized"; }?> </span> </td> <td> <input type="hidden" name="approve[]" id="approve[]" value="0"> <input type="checkbox" name="approve[]" id="approve[]" value="1"> Approve <input type="hidden" name="deny[]" id="deny[]" value="0"> <input type="checkbox" name="deny[]" id="deny[]" value="1"> Deny </td> </tr> <?php } ?> </table> <input name="submit" type="submit" id="submit" value="Submit"> </form> </p> <?php ?> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="12%"> </td> </tr> </table> </body> </html>
  25. Hey Guys Im having trouble with the following code. as it stands the code works however i need to alter it to do some calculations. the code <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/dbc.php"; include_once($path); page_protect(); company(); $stafflist = mysql_query("SELECT * FROM StaffList WHERE full_name != 'Adam Carter' AND full_name != 'Jakata' AND branch = '$_SESSION[branch]' "); function firstOfMonth() { return date("Y/m/d", strtotime(date('m') -1 .'/01/'.date('Y').' 00:00:00')); } $lastmonth = date("Y/m/d", strtotime(date('m') .'/01/'.date('Y').' 00:00:00'. '- 1 month')); $lastmonth1 = date("Y/m/d", strtotime(date('m') .'/01/'.date('Y').' 00:00:00'. '- 2 month')); $lastmonth2 = date("Y/m/d", strtotime(date('m') .'/01/'.date('Y').' 00:00:00'. '- 3 month')); $lastmonth3 = date("Y/m/d", strtotime(date('m') .'/01/'.date('Y').' 00:00:00'. '- 4 month')); if (isset($_POST['submit'])) { //Assign each array to a variable $id = $_POST['id']; $user_name = $_POST['user_name']; $Serviceamount = $_POST['Serviceamount']; $servicedate = $_POST['servicedate']; $forecast = $_POST['forecast']; $productsales = $_POST['productsales']; $Clientsthismonth = $_POST['Clientsthismonth']; $Personelret = $_POST['Personelret']; $Totalret = $_POST['Totalret']; $colours = $_POST['colours']; $cuts = $_POST['cuts']; $prebooking = $_POST['prebooking']; $timeused = $_POST['timeused']; $limit = count($id); $values = array(); // initialize an empty array to hold the values for($k=0;$k<$limit;$k++){ $msg[] = "$limit New KPI's Added"; $values[$k] = "( '{$id[$k]}', '{$Serviceamount[$k]}', '{$servicedate[$k]}', '{$forecast[$k]}', '{$productsales[$k]}', '{$Clientsthismonth[$k]}' , '{$Personelret[$k]}', '{$Totalret[$k]}', '{$colours[$k]}', '{$cuts[$k]}', '{$prebooking[$k]}', '{$timeused[$k]}', {$productsales[$k]} / {$Clientsthismonth[$k]} * 100 )"; // build the array of values for the query string } $query = "INSERT INTO `Services` (Staffname, ServiceAmount, ServiceDate, ForecastForNextMonth, ProductSales, ClientsThisMonth, personnelRetension, totalRetension, Colours, Cuts, PreBooking, TimeUsed, productpercentage) VALUES " . implode( ', ', $values ); // Form the query string and add the implod()ed values $Event = "INSERT INTO Events (UserName, Event ) VALUES ('$_SESSION[user_name]', 'Entered New KPI' )"; if (!mysql_query($query,$link)){ die('Error: ' . mysql_error()); } else { mysql_query($Event); echo "<div class=\"msg\">" . $msg[0] . "</div>"; } } if (checkAdmin()) { ?> <html> <head> <title>Book Off Holiday</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="php_calendar/scripts.js" type="text/javascript"></script> <?php Header1(); ?> </head> <body> <form name="form" action="/Admin/Newkpi.php" method="post"> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="500" valign="top"> <p> <h3 class="titlehdr">New KPI</h3> <table width="100%" border="0" align="Centre" cellpadding="2" cellspacing="0"> <tr class="mytables"> <td width="160"> </td> <td width="20px"><h3 class="Text2">Staff ID</h3></td> <td width="20px"><h3 class="Text2">Staff Member</h3></td> <td width="20px"><h3 class="Text2">Service Amount</h3></td> <td width="20px"><h3 class="Text2">Service Date</h3></td> <td width="20px"><h3 class="Text2">Forecast For Next Month</h3></td> <td width="20px"><h3 class="Text2">Product Sales</h3></td> <td width="20px"><h3 class="Text2">Clients This Month</h3></td> <td width="20px"><h3 class="Text2">Personel Retension</h3></td> <td width="20px"><h3 class="Text2">Total Retension</h3></td> <td width="20px"><h3 class="Text2">Colours</h3></td> <td width="20px"><h3 class="Text2">Cuts</h3></td> <td width="20px"><h3 class="Text2">Pre-Booking</h3></td> <td width="20px"><h3 class="Text2">Time Used</h3></td> <td width="160"> </td> </tr> <?php while ($rrows = mysql_fetch_array($stafflist)) {?> <tr> <td width="160"> </td> <td><h3 class="Text3"><input type="" name="id[]" id="id[]" size="4" value="<?php echo $rrows['id'];?>" /></h3></td> <td><h3 class="Text3"><input type="" name="user_name[]" id="user_name[]" value="<?php echo $rrows['full_name'];?>" /></h3></td> <td><h3 class="Text3"><input name="Serviceamount[]" type="text" size="8" id="Serviceamount[]"></h3></td> <td><h3 class="Text3"><input name="servicedate[]" type="text" value="<?php echo firstOfMonth();?>"size="11" id="servicedate[]"></h3></td> <td><h3 class="Text3"><input name="forecast[]" type="text" size="8" id="forecast[]"></h3></td> <td><h3 class="Text3"><input name="productsales[]" type="text" size="8" id="productsales[]"></h3></td> <td><h3 class="Text3"><input name="Clientsthismonth[]" type="text" size="4" id="Clientsthismonth[]"></h3></td> <td><h3 class="Text3"><input name="Personelret[]" type="text" size="4" id="Personelret[]"></h3></td> <td><h3 class="Text3"><input name="Totalret[]" type="text" size="4" id="Totalret[]"></h3></td> <td><h3 class="Text3"><input name="colours[]" type="text" size="4" id="colours[]"></h3></td> <td><h3 class="Text3"><input name="cuts[]" type="text" size="4" id="cuts[]"></h3></td> <td><h3 class="Text3"><input name="prebooking[]" type="text" size="4" id="prebooking[]"></h3></td> <td><h3 class="Text3"><input name="timeused[]" type="text" size="4" id="timeused[]"></h3></td> <td> </td> </tr> <?php } ?> </table> <input name="submit" type="submit" id="submit" value="Create"> </table> </form> </body> </html> <?php } ?> from here what i need it to do is on each insert using the array it needs to 1. look up the current users id in services 2. look at the date what has just been inserted and get the 3 PREVIOUS services ( so if its marked as the 1/6/2011 then it needs to pull 01/05/2011, 01/04/2011 and 01/03/2011) 3. it then needs to add the cuts values from that query together and add the colours values together then divide the cuts total by the colours total to get a ratio. 4. then finally store the result of that sum into a field called cutscolourpercentage. now the way im looking at it is to do an if function inside the current if function but i just cant seem to get the code right any help would be amazing please
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.