Jump to content

JayJ

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JayJ's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys, I got some help somewhere else.  Here's what's working for me... [code] <?php $result = mysql_query("SELECT *,Uname, date_format(time, '%e') as fmt, date_format(time, '%b') as fmt2, date_format(time, '%Y') as fmt3 FROM loginphp order by Uname asc")  or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $user = stripslashes($row['Uname']); // username $name = stripslashes($row['Fname']); // first name $email = stripslashes($row['Email']); // email address $status = stripslashes($row['status']); // membership status: trial, monthly, yearly $regtime = stripslashes($row['fmt']);  // day of registration $month = stripslashes($row['fmt2']); //month of registration $year = stripslashes($row['fmt3']); //year of registration $day = date("d"); $day2 = $day - 21; // 7 day trial expiry email notice $day3 = $day - 28; // trial period $trial_mon = date("M"); //current month $trial_year = date("Y"); //current year if($status == 0) // Tries only those on a trial membership, which is STATUS = 0 { if($trial_mon == $month && $trial_year == $year) { if($regtime == $day2) { echo "$user: SEND NOTICE<br>"; // Sends a 7 day notice for expiry } else { if($regtime <= $day3) { echo "$user: DISABLE USER<br>"; // Deletes user account } else { echo "$user: ALLOW USER<br>"; } } } else { if($trial_year - $year == 1 && $trial_mon == $month) { $days = 31-$regtime; $days = $days+$day; if($days == $day2) { echo "$user: SEND NOTICE<br>"; } else { echo "$user: ALLOW USER<br>"; } } else { if($days <= $day3) { echo "$user: DISABLE USER<br>"; } else { echo "$user: SEND NOTICE<br>"; } } } } } ?> [/code] Enjoy!
  2. ldoozer, I'm not sure using a VARCHAR would work.  I tried that with another function in my script, but I ended up having to change it to DATETIME.  Maybe that's a better route for us. If we could simply extract the Month and Day individually from the date field.  Then coding some simple math equations would be rather easy, I think. Do you know how to pull, say, a date('d') into a single $variable?  I've tried, but got no effect yet.  Something like... [code] <?php $datereg = $row['datereg']; // Get date from database $dayreg = date('d', $datereg); // Pull out the day value out of the stored date. $dayexp = date('d')-20; // substract 20 days off of today to get the 20 day expiry. $checkuser = $dayreg - $dayexp // get the difference If($checkuser > 0) // if the value is positive, it should be expired { EXPIRED; } else { ALLOWED; } ?> [/code] Of course, we'd have to take into consideration when the month (and year) change.  Some more simple equations.  But, certainly, there's got to be an easier way!  I'm a noob to this stuff. What do you think?
  3. Well, when I take the difference from a timestamp, I get something like this... -2.0068932674E+13 No wonder I was getting back inaccurate stuff.  How can I take the difference when the results aren't even coming back as a number? Some suggestions on this would be very helpful.
  4. [quote author=ShogunWarrior link=topic=124136.msg515692#msg515692 date=1170020911] You have to remember that if today is the 4th then 4-20 is -16 and you need to go back a month. [/quote] What's the best way to implement that into my code?
  5. Hey guys, been fiddling with this code, but I still can't seem to get it to do what I want.  A little help? Again, I want users to have a trial period of, say, 20 days.  When 20 days expires, their user account is disabled. Any suggestions? [code] <?php $result = mysql_query("SELECT * FROM loginphp") or die(mysql_error()); $num=mysql_numrows($result); $i=0; while ($i < $num) { $row = mysql_fetch_array( $result ); $time = $row['time'];  // Time of registration $trial = mktime(00, 00, 00, date('m'), date('d')-20, date('Y')); $difference = $trial - $time; If($difference < 20) { echo "<font face=verdana size=2>DISABLE USER: " . $row['Uname'] . "</font><br>"; } else { echo "<font face=verdana size=2>ALLOW USER: " . $row['Uname'] . "</font><br>"; } $i++; } ?> [/code]
  6. Thanks a million, Huggie.  Everything's working perfectly now!
  7. HuggieBear, you're right.  I got mixed up with another post.  Oops.  ::) I did change it to DATETIME, and it worked like a charm. But that leads me to another problem... what kind of function do I use to record the date when I create a blog? I was using... [code] $time = date('M j Y'); [/code] But that doesn't work anymore. And one last thing.  If I want to display the date in a certain format in the blog, how would I do that from a DATETIME so it displays differently? I want it to read [b]Jan 28, 2007[/b].
  8. I did use the code you gave me, but when I ran it, nothing displayed. [quote author=HuggieBear link=topic=124402.msg515359#msg515359 date=1169988287] You need to use the time column to order the posts, it's best to do this in MySQL [/quote] I'm not sure exactly what you mean here.  Do you mean I have to change something within my database?  And like I mentioned my ['time'] is a VARCHAR.  WOuld you recommend changing that to something else? Also, I do have an ID column for each blog.  Could I somehow use that, and run it backwards?
  9. I want to display information backwards, like a blog, where Jan 28's data appears on top, then Jan 27's underneath, etc. This is what I got, but I can't getting it to display yet... [code] $result = mysql_query("SELECT * FROM blogs") or die(mysql_error()); $num=mysql_numrows($result); $i = $result; while ($i > 0) { $Title=mysql_result($result,$i,"Title"); $File=mysql_result($result,$i,"File"); $Description=mysql_result($result,$i,"Description"); $Time=mysql_result($result,$i,"Time"); DISPLAY INFO; $i = $i - 1; } [/code] Am I on the right track or way off?  Is there an easier way?
  10. Thanks guys.  So far, I only know very basic php.  So your help is appreciated. I do have a couple more questions though. Right now, I insert the registration time into my database like this... [code] $regtime = date('M,j,Y');  // I record it as a VARCHAR [/code] Can I leave it like this and use the mktime() function, or do I need to change both the way I record it and the variable type, or just one? If I don't have to change any of that, do I continue like this... [code] $regtime = mktime(0, 0, 0, date("m")-1, date("d"),  date("Y")); $currentstatus = $regtime - $expiretime; If($currentstatus < 0) { DISABLE USER; } else { ALLOW USER; } [/code]
  11. Hi all, I want to be able to disable a user account after a month. How do I subtract today's date from the stored date?  Here's my basic code... $timein = $row['timein']; $timenow = date('M j Y'); $difference = $timein - $timenow; If($difference > 30) { DISABLE ACCOUNT } But how do I take the difference between dates if they're in a 'M j Y' format.  Does PHP know how to make the difference? Thanks. Jay
×
×
  • 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.