Jump to content

jdorma0

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by jdorma0

  1. Per GDPR article 17 I'd like to request that all of my content, including topics (as they contain identifiable information) (https://forums.phpfreaks.com/topic/194707-rank-employees-by-performance-mysql-php-help/, https://forums.phpfreaks.com/topic/194859-display-a-certain-list-of-days-using-date/) and posts, for all intents and purposes, to be deleted and my account closed aka right to be forgotten. Please scrub this post when completed. Cheers.
  2. Great! Yeah, your whichchart variable wasn't being defined once you actually went to a chart.. it attempted to load comments, but it didn't have a chart to pull them from. And the first issue was that your script wasn't getting the variable because it wasn't defined with $_GET. But but modifying like I suggested you corrected those two problems and it's working now, so congrats!
  3. That fixed the biggest problem. Now change the end of your script to this: if ($pagenum == 1) { } else { $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&whichchart=".$_GET['whichchart']."'><<-First</a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous&whichchart=".$_GET['whichchart']."'><-Previous</a> "; } if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next&whichchart=".$_GET['whichchart']."'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last&whichchart=".$_GET['whichchart']."'>Last ->></a> "; } ?> in place of if ($pagenum == 1) { } else { $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'><<-First</a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'><-Previous</a> "; } if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?>
  4. First of all, change this if (!(isset($pagenum))) { $pagenum = 1; } to this if (!(isset($_GET['pagenum']))) { $pagenum = 1; }else{ $pagenum = $_GET['pagenum']; } Let me know when it's uploaded, I'll check it out again.
  5. You're welcome! Let me know if you need anything else.
  6. No problem. Let me know if it works or if it helped.
  7. Your form is using method=post. Why are you using $_GET['whichchart']? Should be $_POST['whichchart'] or change your form to method=get. That's the main thing I noticed. Got a live URL?
  8. $cat_id = $_GET['cat_id']; $state = $_GET['state']; if (($cat_id == "00") && ($state == "00")) { $query = "SELECT name,address,city,state,zip,phone,web,other FROM ydc ORDER BY name ASC"; } else if (($cat_id != "00") && ($state == "00")) { $query = "SELECT name,address,city,state,zip,phone,web,other FROM ydc WHERE cat_id = $cat_id ORDER BY name ASC"; } else if (($cat_id == "00") && ($state != "00")) { $query = "SELECT name,address,city,state,zip,phone,web,other FROM ydc WHERE state = '$state' ORDER BY name ASC"; } else { $query = "SELECT name,address,city,state,zip,phone,web,other FROM ydc WHERE cat_id = $cat_id AND state = '$state' ORDER BY name ASC"; } $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) == 0) { echo "<h3>Sorry, there are no listings that match your selection.</h3>"; } else { while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $name = $row['name']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $phone = $row['phone']; $web = $row['web']; $other = $row['other']; echo "<h3>$name</h3>"; echo "$address<br />"; echo "$city, $state $zip<br />"; echo "$phone<br />"; echo "<a href=http://$web>Visit Website</a><br />"; echo "$other"; echo "<h2> </h2>"; } } Try that. I think that will work because you have to use quotes whenever the data is not a integer.
  9. Well, I actually created a live test of your code on my server and it's operating exactly as intended. http://www.widocomputers.com/smarttime/EmptyPHP.php Just click the different conditions at the bottom of the page to see it in action. I'm not using the queries though, I'm just testing the conditions.
  10. Why don't you replace die('Sorry, could not get the listings at this time, please try later'); with die(mysql_error()); Just to see if you get any errors on those other two conditions.
  11. Yes sir. I know I should start another topic for this, but maybe you will know the answer. I need to prefill a select field for each row of my form. echo "<div align=\"center\"><font color=\"red\"><b>WARNING:</b> Only use the results for the week ending on <b>".$vars['emp_date']."</b></font></div><br />"; ?> <table align="center" class="style6"> <tr> <th>Employee</th> <th>Star</th> <th>CSAT</th> <th>CPH</th> <th>PA</th> <th>Credit</th> <th>Attachments</th> </tr> <?php echo '<form action="insert.php" method="post">'; $i=0; while($i<$vars['emp_num']) { $emp = "<tr><td><select name=\"row_associd_$i\">"; $res = mysql_query("SELECT * FROM employees WHERE department='".$_POST['emp_department']."'"); $emp .= "<option \"\">Select Employee</option>"; while($emps = mysql_fetch_array($res)) { $emp .= "<option value=".$emps['associd']; // $emp .=" selected"; // Need to decide how to get this to output, skipping the last person $emp .=">".$emps['fname']." ".$emps['lname']."</option>"; } $emp .= "</select></td>"; $emp .= "<td><input type=\"text\" size=\"5\" name=\"row_star_$i\">"; $emp .= "</td><td><input type=\"text\" size=\"5\" name=\"row_csat_$i\">"; $emp .= "</td><td><input type=\"text\" size=\"5\" name=\"row_cph_$i\">"; $emp .= "</td><td><input type=\"text\" size=\"5\" name=\"row_pa_$i\">"; $emp .= "</td><td><input type=\"text\" size=\"5\" name=\"row_credit_$i\">"; $emp .= "</td><td><input type=\"text\" size=\"5\" name=\"row_attachments_$i\">"; $emp .= "</td></tr>"; echo $emp; $i++; } ?> </table> <input type="hidden" name="emp_i" value="<?php echo $i;?>"> <input type="hidden" name="action" value="emp_processrows"> <input type="submit" name="emp_submit" value="rank employees"> </form> Basically, I would like to have selected each person for the row. Example: Bob Jones - selected Mary Beth - not selected Frank Sinatra - not selected Bob Jones - not selected Mary Beth - selected Frank Sinatra - not selected Bob Jones - not selected Mary Beth - not selected Frank Sinatra - selected I was playing around with it but I couldn't get it figured out. I'd appreciate it if you could help me with that one too.
  12. Thanks so much! With a little modification: $week = 60*60*24*7;//60 secs a min * 60 mins an hour * 24 hours a day * 7 days a week $time = strtotime("last sunday"); for ($i = 0; $i < 10; $i++){ $etime = "<option value=\"".date("Y-m-d", $time)."\""; if($i==1) { $etime .="selected"; } $etime .= ">".date("Y-m-d", $time) . "</option>"; echo $etime; $time -= $week; } It works like a charm! I appreciate it.
  13. $newID = "SELECT `id` FROM `jobs` ORDER BY `id` LIMIT 1"; $getID = mysql_query($newID); if($getID): while($nid = mysql_fetch_assoc($getID)): $id = $nid['id']; endwhile; if($id == 0): $id = 1; endif; else: return 'Failed to complete your request to open a new job, please contact support.'; endif; Give that a whirl.
  14. Basically, I need to prefill a select drop down box with the sunday of each week. I would like to it to basically be in the format of: <select name="row_date"> <option value="2010-01-01">2010-01-01</option> <option value="2010-01-08">2010-01-08</option> <option value="2010-01-15">2010-01-15</option> <option value="2010-01-22">2010-01-22</option> etc. etc. </select> But it would automatically select the current week (as the default value) and allow the user to change that.. but only from the displayed dates. I wouldn't need more than 6 weeks to be shown, but that's not too important. I've researched this forum, php.net and Google to no avail. Hopefully one of you bright people can help me out! Thanks! =] Joey
  15. No I believe mysql_fetch_array will return actual values instead of references so closing it shouldn't be a problem since $row is a regular php array and has nothing to do with the database link. Oh okay, I figured it would be that but I threw it out there because I wasn't 100% sure.
  16. Courtesy of PHP.net: <?php function strip_only($str, $tags) { if(!is_array($tags)) { $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) $str = preg_replace('#</?'.$tag.'[^>]*>#is', '', $str); return $str; } $str = '<p style="text-align:center">Paragraph</p><strong>Bold</strong><br/><span style="color:red">Red</span><h1>Header</h1>'; echo strip_only($str, array('p', 'h1')); echo strip_only($str, '<p><h1>'); ?> So, in your case, call the function as: echo strip_only($str,array('a','span')); //echoing so you can see the output Hope that helps! Joey
  17. I know this is pretty much a given, but have you checked to make sure your database's admin field is set to 1 for that user? And also, I'm not sure if this would cause any problems or not, but since the mysql_close is closed before you set the variables... would that create an issue? (a seasoned pro will hopefully answer this =) // Register the values & redirect. $row = mysql_fetch_array ($result, MYSQL_NUM); mysql_free_result($result); mysql_close(); // Close the database connection. $_SESSION['admin'] = $row[1]; $_SESSION['username'] = $row[0]; And as Aeroswat noted, change the if statement to admin==1 instead of ===. Other than that that's the only issues I see. Joey
  18. This should do the job for you. It combines PHP, cookies and JavaScript. May not be the prettiest, but it gets the job done. Just call upon this function when the user logs in. You may need to customized it to get it right for your setting. <?php function cTimer(){ if(!isset($_COOKIE['LoginTimer'])) { setcookie ("LoginTimer", "TRUE", time() + 5); # This cookie set for to 5 seconds for testing [comment this when you're ready to use it] #setcookie ("LoginTimer", "TRUE", time() + 7200); # 2 hour cookie [remove the # symbol at the beginning of this line when you go live with the script] echo <<<JS <script language="JavaScript"><!-- window.alert('Please call'); //--></script> JS; } } cTimer(); //Call the cTimer function when you need the timer to be used ?> Let me know if that works for what you need. Joey
  19. Okay, after another night of failure trying to figure this out I am going to go to bed. If anyone can help me out, I would greatly appreciate it, but it just seems like my topic keeps sliding off the first few pages =[ Any suggestions anyone?
  20. I would say create a sitemap for your website and research the robots.txt file .. but it looks like you've already created http://www.midsouthcoin.com/sitemap.xml If you look at the priority in the sitemap (I'm using Google Chrome, not sure if IE will do this) it lists your homepage at 1.00 while all of your subpages are 0.50. Some major search engine optimization is required. I would recommend adding more to your homepage, providing a brief description of the business (there's more information on the store page than the homepage), with a few contextual links to the store, as well as getting other web sites to link to your store. You can get listed in a few directories online that will help you, but be careful and not get on websites which list thousands of links on one page because that'll hurt your ranking. If you follow this Google search, it has your site listed. http://www.google.com/search?hl=en&rlz=1C1GGLS_enUS368US368&q=midsouthcoin.com/midsouthcoinstore/&aq=f&aqi=&aql=&oq= The problem is it has the wrong link listed.. one that apparently leads back to Zen Cart. Another problem is that Zen Cart itself is not very search engine friendly as just about everything draws off of the index.php file.. which to a search engine looks like everything is one page so it just picks a page to cache and calls it quits. You can use a SEO for Zen Cart, which will rewrite your URLs to look as if they are static HTML pages, but are still entirely dynamic. It will help with the search engine caching. But use it at your own risk and back up your store before you install it (any files that you change, etc). http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_47&products_id=231 Good luck! Joey
  21. Additionally (sorry, the modify buton wasn't there!), the data is compared to each employee before going to the database if my thinking is correct. Thanks!
  22. It also could be that I need to do the ranking when the data is first inserted into the database. But then again I realize the problem that I don't know how to rank the data given multiple rows (employee 1, 2, 3, 4, etc) .. again in Excel I would just use the rank() function to process it. But I have to get this web based and use the power of PHP to do that. Also, the fields credit and attachments would be the only ones using a percentage mark (%).
  23. I am trying to write a script that will allow the user to input data (people and their performance) into the database using a form, and then once this data enters the database I would like to be able to rank the people by their performance, thus helping management decide who gets their choice of hours versus the lower ranking employees. I've setup the database like this: empdata id empid edate star csat cph pa credit attachments olrank idempidedatestarcsatcphpacreditattachmentsolrank 14532010-02-288029712.0281%51%0 26582010-02-28258200-5.0255%360 335342010-02-281001515022.02%100%78%0 And so far my script looks like... <?php include_once("header.inc");?> <table align="center" class="style6"> <tr> <th>First Name</th> <th>Last Name</th> <th>Star</th> <th>CSAT</th> <th>CPH</th> <th>PA</th> <th>Credit</th> <th>Attachments</th> <th>Ranking</th> </tr> <?php $query = "SELECT * FROM empdata"; $res = mysql_query($query); $i=0; while($earray = mysql_fetch_array($res)) { $empname = mysql_query("SELECT * FROM employees WHERE associd=".$earray['empid']); $ename=mysql_fetch_array($empname); $emp = "<tr><td>".$ename['fname']; $emp .= "</td><td>".$ename['lname']; $emp .= "</td><td>".$earray['star']; $emp .= "</td><td>".$earray['csat']; $emp .= "</td><td>$".$earray['cph']; $emp .= "</td><td>".$earray['pa']; $emp .= "</td><td>".$earray['credit']; $emp .= "%</td><td>".$earray['attachments']; $emp .= "%</td><td>".$earray['olrank']; $emp .= "</td></tr>"; echo $emp; $i++; } ?> </table> <?php include_once("footer.inc");?> My main problem is figuring out how to do the formulas. If it were Excel I would simply use the rank function on each of the fields. I need to rank each field individually (cph, credit, pa, etc, etc) and rank each employee by that field, then add that to the olrank column. The olrank would be a sum of each of the ranks (example: credit 2nd, pa 1st, csat 4th would mean that person gets scored 7 pts) that I would just retrieve from the database using a reverse BY olrank directive. Any help would be appreciated. Thank you so much. I've been trying to figure out these formulas for days. Joey EDITED: Formatting went wack. Corrected. Sorry! - Joey
×
×
  • 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.