Acolyte Posted April 6, 2020 Share Posted April 6, 2020 Hey all, This code was given to me by my client who swears it works, yet I can't seem to get it to function. I'm only basically knowledgeable regarding coding. But as I understand, it's in two parts, where variables are declared in the php portion, which are then used in the javascript snippet. The code is simply supposed to display a number that updates daily. Any help is greatly appreciated. <?php $now = time(); // or your date as well $your_date = strtotime("2016-06-01"); $datediff = $now - $your_date; $referrals = number_format(162250 + (floor($datediff/(60*60*24)) * 527) + (87920 + (floor($datediff/(60*60*24)) * 45))); ?> //javascript: <script> //vars from template var referrals = "<?php echo $referrals;?>"; var currentdate = new Date(); jQuery("document").ready(function() { jQuery ("#sp-menu > div > nav > ul > li:nth-child(1) > a").html("Home"); jQuery(".referrals").html(referrals); jQuery(".current_date").html((currentdate.getMonth()+1) + "/" + currentdate.getDate() + "/" + currentdate.getFullYear()); jQuery(window).on("scroll", function() { var scrollPos = jQuery(window).scrollTop(); if (scrollPos <= 0) { jQuery(".counter").fadeIn(); jQuery(".sec-nav").fadeIn(); } else { jQuery(".counter").fadeOut(); jQuery(".sec-nav").fadeOut(); } }); }); </script> Quote Link to comment Share on other sites More sharing options...
requinix Posted April 6, 2020 Share Posted April 6, 2020 2 hours ago, Acolyte said: This code was given to me by my client who swears it works, yet I can't seem to get it to function. a) If they say it works but it doesn't function then it doesn't work b) How is it broken? This isn't our code, we can't see it on the site, we don't know anything other than the few bits you've posted. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 6, 2020 Share Posted April 6, 2020 And why do you want to get into this? You don't code. Suddenly you want to run some code? Why? Quote Link to comment Share on other sites More sharing options...
Acolyte Posted April 6, 2020 Author Share Posted April 6, 2020 11 hours ago, requinix said: a) If they say it works but it doesn't function then it doesn't work b) How is it broken? This isn't our code, we can't see it on the site, we don't know anything other than the few bits you've posted. a. It seems to work on this site: lawyerspiprogram.com. I however, can't get the code to run on I site they asked me to put together. b. I'm not certain about the "isn't our code" comment. Does it have to be? 6 hours ago, ginerjm said: And why do you want to get into this? You don't code. Suddenly you want to run some code? Why? Because I was tasked to put a site together and this code snippet is part of the job. I came here for a bit of guidance. Do I have to be a coder? Has this post offended for some reason? This isn't the friendliest of welcomes. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 6, 2020 Share Posted April 6, 2020 Well if you are not a coder but you are being asked to do stuff like this you're going to have a heck of a time doing your job. Does your boss know that you don't have the tools for the job he/she has assigned you? Quote Link to comment Share on other sites More sharing options...
Acolyte Posted April 6, 2020 Author Share Posted April 6, 2020 Just now, ginerjm said: Well if you are not a coder but you are being asked to do stuff like this you're going to have a heck of a time doing your job. Does your boss know that you don't have the tools for the job he/she has assigned you? I was considering this site as part of the tools I could use to complete the job. It's just a simple snippet. I've worked with code in the past and have been successful, it's just that I'm having a problem working this one out. This is a bit strange. Other forums just help without this judgment. Perhaps I've come to the wrong forum. Thank you. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 6, 2020 Share Posted April 6, 2020 You told us of your weakness. I simply told you that it was going to be difficult. I did look at the code a bit and aren't quite sure what you are describing. Looks like more date manipulation rather than a counter. And it has a lot of JQ in it which isn't part of this PHP forum's area of expertise. Quote Link to comment Share on other sites More sharing options...
requinix Posted April 6, 2020 Share Posted April 6, 2020 I think that was ginerjm is trying to say is that this may not be the easiest thing in the world for you, but even though there are some people here who don't know stuff like jQuery very well, I know we can help you out in one way or another. I'm sure he wasn't trying to gate-keep the world of software development and say that you had to give up. Right, ginerjm? 5 hours ago, Acolyte said: b. I'm not certain about the "isn't our code" comment. Does it have to be? What I mean is that we don't know anything about your code short of what you can post here and tell us about. As people who have never seen it before, you automatically know more about it (as a whole) than we do. It's not exactly like we can just jump right into the middle of all this and tell you exactly what needs to happen. 5 hours ago, Acolyte said: a. It seems to work on this site: lawyerspiprogram.com. I however, can't get the code to run on I site they asked me to put together. It's good to know it works somewhere, but if you need help getting it to work someplace it does not then it'd be more helpful if we knew more about that, right? The PHP code is simple enough so any problem is likely to be with the Javascript side. Any errors in the browser console? And the general troubleshooting questions apply: what is it supposed to be doing and what is it actually doing? 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.