Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

davidcriniti's Achievements


Member (2/5)



  1. I have a table where I'm storing my marathon and other race results. One column ( race_time_total - TIME format) and another column ( race_distance_numeric - decimal(65,3) format) are being used here. Assuming the race_distance_numeric is the distance of the race in either km or miles (Eg: marathon being 42.195km), how to I calculate the pace? I've used: $pace_per_k = $row_content['race_time_total'] / $row_content['race_distance_numeric'] .... but am not getting expected results when I echo $pace_per_k Any tips?
  2. Oops, found the error: (Missing "_" in $_SESSION) $sql_date_last_login = $pdo->exec("update members set date_last_login = now() where member_id = '".$_SESSION['member_id']."'");
  3. I'm making an amendment to my login page so that when a user logs in, the date_last_login field in the members table is updated to NOW(). Well, that's the idea. The login works fine. Always has. It's just this update that isn't happening. No error message appears, but date_last_login remains 0000-00-00 00:00:00 . Any tips? $sql_date_last_login = $pdo->exec("update members set date_last_login = now() where member_id = '".$SESSION['member_id']."'"); Cheers, Dave
  4. Hi all, I have a search page where I'd like members to be able to search for races that they and their friends have entered into a database. When entering the data, users put the race date into the race_date field (Which is a DATETIME field) in the table. I've set up the search and display pages, so users can search by a number of other criteria (first name, last name, race distance, time, etc), but am having trouble with searching by year. On my search form, is a field called race_year. So, obviously I need some change in the code below, specifically in relation to the line $where .= " AND race_date='$race_year'"; because I want to extract the year part of the race_date column from the table and see if it matches $race_year . Any advice would be appreciated. Cheers, Dave $race_year = $_POST['race_year']; if ($race_year != '') { // A year is selected $where .= " AND race_date='$race_year'"; }
  5. Hi everyone, My googling seems to have found an way to add x days to the current date, and I'm sure that finding x days from a date pulled from my database must be pretty similar, but I just can't seem to get it working. My task involves teachers setting notifications which are displayed for a number of days designated by the teacher. So when the teacher creates the notiication, the `notificatin_date` field is updated with the timestamp. The `notification_duration` field is an integer between 1 and 21. I can get this info out of the database without problem: $notification_set = date('Y-m-d', strtotime($notification['notification_date'])); $notification_duration = $notification['notification_duration']; echo $notification_duration . "<br/>"; echo $notification_set . "<br/>"; However, when I try and add the duration to the date when the notification was set, to echo the expiry date, I run in to problems. This is what I've got at the current time, but I'm obviously not 'adding' $notification_duration and $notification_set correctly in the first line below, which is causing all my problems. Any help is much appreciated. $expiration_date = $notification_set + strtotime($notification_duration . "days"); if ($expiration_date> date) { echo "Your notification will expire on "; } else if ($expiration_date < date) { echo "Your notification expired on "; } else echo "Your notification expires today "; echo date('jS', strtotime($expiration_date)); echo " of "; echo date('F', strtotime($expiration_date)); echo ", "; echo date('Y', strtotime($expiration_date)); Thanks for your time, Dave
  6. Thank you both for your responses. The time column was always formatted as TIME, so that wasn't a problem. Adding the `backticks` seemed to make all the difference fastsol, so thanks for that tip! $time_stated = $_POST['time_stated']; if ($time_stated != '' ) { $where .= " AND `time` < '$time_stated'"; } Cheers, Dave
  7. Hi everyone, I've got a simple script that is searching for the results of running races in a database. Searching for a finisher's position works perfectly with this script: $position = $_POST['position']; $pos_operator = $_POST['pos_operator']; if ($pos_operator == '=' && $position != '' ) { $where .= " AND position='$position'"; } if ($pos_operator == '<' && $position != '' ) { $where .= " AND position<'$position'"; } $position refers to a text field in the form where the user can type in a digit. $pos_operator refers to a text field in the form where a user can select = or < However, when I try to do a similar thing with time, I'm not getting the expected results. $time_stated = strtotime($_POST['time_stated']); if ($time_stated != '' ) { $where .= " AND time < '$time_stated'"; } $time_stated refers to a text field where the user is asked to look for a time less than the time they input in xx:xx:xx format. I tried this with and without the strtotime Any tips? Cheers, Dave
  8. Hi everyone, On our school website, we've got a page where students can do a quiz, and get feedback given to them, as to whether their answers are correct or incorrect. The code echos the student response for each question, and the feedback, tick / cross is displayed in the adjacent column. However, I've just changed the input box from a text field to a text area, and I've noticed a little quirk. The student answer, after pressing submit, now displays in lower case. Is their any way I can echo their answer, exactly as they input it. Here is the relevant code: <textarea name="user_answer_<?=$row_counter?>" cols="40" rows="2" /><?=$userAnswer?></textarea> Thanks for your time, Dave
  9. Sorry. Simple error. Forgot to account for scenario with points less than the first level. if ($total < 50) { $level= ""; }
  10. Hi, I'm trying to develop an online merit award system for our school at the moment. I've got a table that notes the different types of awards that students can get, in various columns, with the last column providing a total points. Some awards are worth different points, which is why $total is calculated as: $total['total'] = $row_recipients['pb4l'] + $row_recipients['pb4l'] + $row_recipients['sports_award'] + $row_recipients['offline_sports_award'] + (5 * $row_recipients['welfare_award']) + (5 * $row_recipients['offline_welfare_award']) + (10 * $row_recipients['senior_executive_award']) + (10 * $row_recipients['offline_senior_executive_award']) ; That works fine, and I've calculated each student's total accurately. The next part is what I'm struggling with. Students attain certain levels ($level) based on their total 50 - Bronze, 100 - Silver, 150 - Gold etc. The code for calculating this is: if ($total >= 50 && $total< 100) { $level = "Bronze"; } if ($total >= 100 && $total< 150) { $level = "Silver"; } if ($total>= 150 && $total< 200) { $level = "Gold"; } if ($total >= 200 && $total < 350) { $level = "School Trophy"; } if ($total >= 350 && $total< 500) { $level = "Platinum"; } if ($total >= 500) { $level = "Diamond"; } echo $level ; The level is accurate for the first few rows displayed, where $total has a value greater than 0. But for rows below that, where students have been given no awards, The $level value is the same as the last row with a $total value greater than 0. Please tell me where I'm going wrong. Cheers, Dave
  11. Hi Q695, That is telling me the total number of rows, which my query already does. The part I'm needing help with iis to find the user's rank by comparing the amount of uploads a user has to the amount of uploads all other users have. Ie: User with most uploads would be ranked #1, user with second most uploads would be ranked #2 and so on. Cheers, Dave
  12. Hi, I've got a site where teachers can upload resources to share amongst staff and students. In order to motivate staff to share resources, I'm doing things like introducing badges and ranks etc. My latest bit of script counts the amount of uploads a staff member has. I can also find the total number of staff who've uploaded, but how I'm not sure how to find the current user's ( ie: Where members.member_id = ". $_SESSION['member_id'] ) rank out of that total in terms of the amount of uploads they have. Any advice would be appreciated. Script so far is : $total_uploads = mysql_query("SELECT members.member_id, members.member_firstname, members.member_lastname, COUNT(*) FROM uploads JOIN members ON uploads.member_id = members.member_id GROUP BY uploads.member_id "); $total_uploads_count = @mysql_num_rows($total_uploads); $upload_count = mysql_query("SELECT members.member_id, members.member_firstname, members.member_lastname, COUNT(*) FROM uploads JOIN members ON uploads.member_id = members.member_id AND members.member_id = ". $_SESSION['member_id'] . " GROUP BY uploads.member_id "); while($row_count=mysql_fetch_array($upload_count)) { echo "<tr>"; echo "<td align='right'> Your upload count: </td>"; echo "<td align='left'>" . $row_count['COUNT(*)'] . " (Your rank is __ out of $total_uploads_count </td>"; echo "</tr>"; } echo "</table>";
  13. Thanks Barand. Just to clarify, when you say "Process each line of text at a time" do you mean that my form for the teachers to submit their badge names (and consequently the table tbl_badges) should have a few fields? ...: (badge_line_1 , badge_line_2, badge_line_3 for example ? Cheers, Dave
  • 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.