Guest User

Untitled

a guest
Jan 12th, 2019
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. $username="user";
  3. $password="pass";
  4. $database="DB";
  5.  
  6. mysql_connect(localhost,$username,$password);
  7. mysql_select_db($database) or die( "Unable to select database");
  8. $query="SELECT id, firstname, lastname, town, age, date FROM signin GROUP BY firstname, lastname WHERE Date =< now() - INTERVAL 30 DAY";
  9. $result=mysql_query($query);
  10.  
  11. $num=mysql_numrows($result);
  12.  
  13. mysql_close();
  14. ?>
  15. <table border="1" cellspacing="2" cellpadding="2">
  16. <tr>
  17. <td>ID</font></td>
  18. <td>FirstName</td>
  19. <td>LastName</td>
  20. <td>Town</td>
  21. <td>Age</td>
  22. <td>Date</td>
  23. </tr>
  24.  
  25. <?php
  26. $i=0;
  27. while ($i < $num) {
  28.  
  29. $f1=mysql_result($result,$i,"firstname");
  30. $f2=mysql_result($result,$i,"lastname");
  31. $f3=mysql_result($result,$i,"town");
  32. $f4=mysql_result($result,$i,"age");
  33. $f5=mysql_result($result,$i,"date");
  34. ?>
  35. <?php if (lessThanOneMonthFromNow($f5)){ ?>
  36. <tr>
  37. <td><a href="<?php echo "submit.php?FName=".$f1."&LName=".$f2."&Town=".$f3."&Age=".$f4 ?>">Signin</a></td>
  38. <td><?php echo $f1; ?></td>
  39. <td><?php echo $f2; ?></td>
  40. <td><?php echo $f3; ?></td>
  41. <td><?php echo $f4; ?></td>
  42. <td><?php echo $f5; ?></td>
  43. </tr>
  44. <?php
  45. }
  46. $i++;
  47. }
  48. function lessThanOneMonthFromNow($enteredDate){
  49. return $enteredDate < date("Ymd", mktime(0, 0, 0, date("m")-1, date("d"), date("y")));
  50. }
  51. ?>
Add Comment
Please, Sign In to add comment