Jump to content

webguync

Members
  • Posts

    951
  • Joined

  • Last visited

Everything posted by webguync

  1. Hi, I have some code which is supposed to make a div appear with text inside after a set timed amount has passed. I am trying it out and it does seem to be working (appearing). Here is what I am doing. JavaScript <script language="javascript" type="text/javascript" src="js/Validation.js"></script> <script type="text/javascript"> $setTimeout(function() { $('#object').slideDown().fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50).fadeOut(50).fadeIn(50); }, 2000); //close the message box when the cross image is clicked $("#close_message").click(function() { $("#object").fadeOut("slow"); }); }); </script> and the html looks like this: <div id="object" class="message"> <img id="close_message" style="float:right;cursor:pointer" src="images/12-em-cross.png" /> <p><strong>Your time is up! Please submit your answers!</strong></p> </div> CSS... .message{ border:5px solid #CCCCCC; position:absolute; width:150px; border:1px solid #c93; background:#ffc; padding:5px; right:0px; top : -140px; } any ideas on what I am doing wrong?
  2. can anyone point me in the right direction on this, as far as using the mail() function to accomplish what I need?
  3. I did a google search, but didn't find out what I was looking for. I know how the mail() function works in general, just not sure how to receive the field results from a form.
  4. Hello, I have a form submitting results to a MySQL database. How would I get the results sent to a specific email address, preferably as an excel file attachment?
  5. I have two tables with two fields, both timestamps. I need to set up a Query to subtract the difference in minutes between the two fields (login_timestamp and submit_timestamp). login_timestamp is in a table called 'Candidates' and submit_timestamp is in a table called 'Responses'. I believe I would need to use. SELECT TIMESTAMPDIFF(MINUTE,'2010-05-17 12:26:13','2010-05-17 11:32:45'); but a little unsure about how to from two different tables. Thanks in advance!
  6. Is there a way to disable the submit button using JS on a form after a certain time period (eg: 60 minutes)
  7. ok, thanks. Will give it a try. So for 60 minutes it will be.. function startTimer(){ var t = setTimeout("alert('1 Hour!')",3600000); }
  8. Hi, I am looking to do something similar to the timer code below except, I don't want the user to have to press a button to get the alert, I want it to appear automatically after 1 hour (60 min). How would I alter the code to do this? <html> <head> <script type="text/javascript"> function timedMsg() { var t=setTimeout("alert('5 seconds!')",5000); } </script> </head> <body> <form> <input type="button" value="Display timed alertbox!" onClick="timedMsg()" /> </form> </body> </html>
  9. I think that was my problem is that the user_id's weren't matching up in my two tables. When I match those up, the data displays correctly.
  10. no, I didn't add that till after I knew it wasn't working properly. It didn't have an effect.
  11. yes, the field name is being spelled correctly. Here is the code (I'll go ahead and display all of it, sorry if it is too much). The field in question is login_timestamp and it is in the Editor_Candidates table. <?php ini_set("display_errors","1"); ERROR_REPORTING(E_ALL); $conn = mysql_connect("localhost","uname","pw"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("DBName")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT Responses.editor_name,Answer1,Answer2,Answer3,Answer4,Answer5,Answer6,Answer7,Answer8,Answer9,Answer10,Answer11,Answer12,Responses.submit_timestamp,Editor_Candidates.login_timestamp, TIMESTAMPDIFF(SECOND,submit_timestamp,login_timestamp) as cTime FROM Responses LEFT JOIN Editor_Candidates USING (user_id) "; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo "<tr><td class='name'>{$row['editor_name']}</td></tr>"; echo "<tr><td class='section'><strong>Section 1</strong></td></tr>"; for ($i =1;$i<9;++$i) { echo "<tr><td><p>{$row['Answer'.$i]}</p></td></tr>"; } echo "<tr><td class='section'><strong>Section 2</strong></td></tr>"; echo "<tr><td><p>{$row['Answer10']}</p></td></tr>"; echo "<tr><td class='section'><strong>Section 3</strong></td></tr>"; echo "<tr><td><p>{$row['Answer11']}</p></td></tr>"; echo "<tr><td class='section'><strong>Section 4</strong></td></tr>"; echo "<tr><td><p>{$row['Answer12']}</p></td></tr>"; echo "<tr><td class='section'><strong>Time:</strong></td></tr>"; var_dump($row["login_timestamp"]); echo "<tr><td class='timestamp'>Login Time: " . date('F j, Y g:i:sa', strtotime($row['login_timestamp'])) . "</td></tr>"; echo "<tr><td class='timestamp'>Submit Time: " . date('F j, Y g:i:sa', strtotime($row['submit_timestamp'])) . "</td></tr>"; $formatted_completion_time = formatTime($row['cTime']); echo "<tr><th class='complete'>Completion Time:</th></tr><tr><td>\n"; echo $formatted_completion_time; echo "</td></tr>"; } mysql_free_result($result); ?>
  12. looks like the mysql field 'login_timestamp' is showing up as NULL, but not sure why since the field is populated in MySQL.(?)
  13. well there is definitely a timestamp there when I look at the MySQL table through PHPMyAdmin. How do I use var_dump()) ?
  14. Anyone know why this timestamp would display as December 31, 1969 7:00:00pm In the PHP I have echo "<tr><td class='timestamp'>Login Time: " . date('F j, Y g:i:sa', strtotime($row["login_timestamp"])) . "</td></tr>"; and the MySQL timestamp looks like this. 2010-06-21 16:17:27 the field name is login_timestamp set to type datetime with default of 0000-00-00 00:00:00
  15. ok, just to clarify...this part if( isset($_GET['user_id'] { $id = (int) $_GET['user_id']; //should be an integer anyhow, so cast it as one $query = "SELECT field1, field2, field3 FROM table WHERE user_id = $id"; $result = mysql_query($query); etc., etc. would be what pulls the individual record? and I would change echo "<tr><td class='name'>{$row['editor_name']}</td></tr>"; to this? echo "<tr><td class='name'><a href=\"script_to_get_individual_record.php?user_id=" . $row['user_id'] . "\">" . $row['editor_name'] . "</a></td></tr>";
  16. Hi, I have a webpage which displays results of a form by pulling out the records and displaying in a HTML table based layout. What I want to do is have a page which will be a hyperlink that when clicked will display the record of the individual, instead of everyone on the same page. So if Joe Schmoe filled out the form, there would be Joe Schmoe link which when clicked will only display his results. Need some help in how to do this. Here is my current code which displays all of the table records on one page. <table id="results"> <tr><th>Candidate Name</th></tr> <?php ini_set("display_errors","1"); ERROR_REPORTING(E_ALL); $conn = mysql_connect("localhost","uname","pw"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("Internal")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT Responses.editor_name,Answer1,Answer2,Answer3,Answer4,Answer5,Answer6,Answer7,Answer8,Answer9,Answer10,Answer11,Answer12,submit_timestamp,login_timestamp, TIMESTAMPDIFF(SECOND,submit_timestamp,login_timestamp) as cTime FROM Responses LEFT JOIN Editor_Candidates USING (user_id) "; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo "<tr><td class='name'>{$row['editor_name']}</td></tr>"; echo "<tr><td class='section'><strong>Section 1</strong></td></tr>"; for ($i =1;$i<9;++$i) { echo "<tr><td>{$row['Answer'.$i]}</td></tr>"; } echo "<tr><td class='section'><strong>Section 2</strong></td></tr>"; echo "<tr><td>{$row['Answer10']}</td></tr>"; echo "<tr><td class='section'><strong>Section 3</strong></td></tr>"; echo "<tr><td>{$row['Answer11']}</td></tr>"; echo "<tr><td class='section'><strong>Section 4</strong></td></tr>"; echo "<tr><td>{$row['Answer12']}</td></tr>"; echo "<td>" . date('F j, Y g:i:sa', strtotime($row["submit_timestamp"])) . "</td></tr>"; $formatted_completion_time = formatTime($row['cTime']); echo "<tr><th class='complete'>Completion Time:</th></tr><tr><td>\n"; echo $formatted_completion_time; echo "</td></tr>"; } mysql_free_result($result); ?> </table>
  17. the way I have it now, the only row being displayed is the average score, but it shows up as all zeros. Here is my while loop. while($row = mysql_fetch_array($result)) { //take sum $row = 0; $sum = 0; for ($i = 1; $i <= 8; $i++){ $sum += $row['score'.$i]; } $average = round($sum/8); //round $average $average = round($row['average'], 1); //count Call Numbers and list by date entered $count = 0; $CallNumber = 1; $currentID = $row['employee_id']; if($count == 0 || $currentID != $previousID) { $CallNumber = 1; } else { $CallNumber++; } echo "<tr>"; echo "<td>" . $row['employee_id'] . "</td>"; echo "<td>" . ucwords($row['employee_name']) . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['score1'] . "</td>"; echo "<td>" . $row['score2'] . "</td>"; echo "<td>" . $row['score3'] . "</td>"; echo "<td>" . $row['score4'] . "</td>"; echo "<td>" . $row['score5'] . "</td>"; echo "<td>" . $row['score6'] . "</td>"; echo "<td>" . $row['score7'] . "</td>"; echo "<td>" . $row['score8'] . "</td>"; echo "<td>" . $average . "</td>"; echo "<td>" . $row['assessor_name'] . "</td>"; echo "<td>" . $row['assessor_id'] . "</td>"; echo "<td>" . $CallNumber . "</td>"; echo "<td>" . $row['date_created'] . "</td>"; echo "<td>" . $row['date_uploaded'] . "</td>"; echo "</tr>"; $previousID = $currentID; $count++; } echo "</table>"; mysql_close($con); ?>
  18. thanks. I have having trouble figuring out where in the while loop this code needs to go to work. I tried right after the left curly brace here: while($row = mysql_fetch_array($result)) { but that didn't work at all.
  19. I have a database with 8 fields all containing numbers from 1-7 and I have another field called 'average' where I am seeking to average the data. I am getting an error with the code I have which is "Warning: Cannot use a scalar value as an array in /var/www/vhosts/etsi-dataservices.com/httpdocs/NNPrinceton/Phase1A_May27_2010/report/Individual_Scores.php on line 59 Warning: Cannot use a scalar value as an array in /var/www/vhosts/etsi-dataservices.com/httpdocs/NNPrinceton/Phase1A_May27_2010/report/Individual_Scores.php on line 62" not sure what this means. Anyway what I have is not working! Here is the entire code. <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Phase1A Award Results - May 2010</title> <link href="report.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Phase1A Award Results - May 2010</title> <link href="css/report.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <?php ini_set("display_errors","1"); ERROR_REPORTING(E_ALL); $con = mysql_connect("localhost","username","pw"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBName", $con); $result = mysql_query("SELECT employee_id,employee_name, roster_Phase1A_May27_2010.title,assessor_id,assessor_name,score1,score2,score3,score4,score5,score6,score7,score8,average,date_created,date_uploaded FROM rpc1A_May27_2010 LEFT JOIN roster_Phase1A_May27_2010 USING (employee_id) ORDER BY employee_id, date_uploaded ASC") or die(mysql_error()); echo "<table> <tr> <th>Employee ID</th> <th>Employee Name</th> <th>Employee Title</th> <th>score 1</th> <th>score 2</th> <th>score 3</th> <th>score 4</th> <th>score 5</th> <th>score 6</th> <th>score 7</th> <th>score 8</th> <th>Average Score (1-</th> <th>Assessor Name</th> <th>Assessor ID</th> <th>Call Number (1-4)</th> <th>Date Created</th> <th>Date Uploaded</th> </tr>"; //take sum $row = 0; $sum = 0; for ($i = 1; $i <= 8; $i++){ $sum += $row['score'.$i]; } $row['average'] = $sum/8; //round $average $row['average'] = round($row['average'], 1); //count Call Numbers and list by date entered $count = 0; $CallNumber = 1; while($row = mysql_fetch_array($result)) { $currentID = $row['employee_id']; if($count == 0 || $currentID != $previousID) { $CallNumber = 1; } else { $CallNumber++; } echo "<tr>"; echo "<td>" . $row['employee_id'] . "</td>"; echo "<td>" . ucwords($row['employee_name']) . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['score1'] . "</td>"; echo "<td>" . $row['score2'] . "</td>"; echo "<td>" . $row['score3'] . "</td>"; echo "<td>" . $row['score4'] . "</td>"; echo "<td>" . $row['score5'] . "</td>"; echo "<td>" . $row['score6'] . "</td>"; echo "<td>" . $row['score7'] . "</td>"; echo "<td>" . $row['score8'] . "</td>"; echo "<td>" . $row['average'] . "</td>"; echo "<td>" . $row['assessor_name'] . "</td>"; echo "<td>" . $row['assessor_id'] . "</td>"; echo "<td>" . $CallNumber . "</td>"; echo "<td>" . $row['date_created'] . "</td>"; echo "<td>" . $row['date_uploaded'] . "</td>"; echo "</tr>"; $previousID = $currentID; $count++; } echo "</table>"; mysql_close($con); ?> </body> </html> </body> </html> the specific code I am trying to do the averaging is... //take sum $row = 0; $sum = 0; for ($i = 1; $i <= 8; $i++){ $sum += $row['score'.$i]; } $row['average'] = $sum/8; //round $average $row['average'] = round($row['average'], 1)
  20. thanks, will give that a try! Hopefully that will solve the problem.
  21. yea, I think I will try that route, thanks.
  22. that makes sense, but can I combine the two queries the way I am currently pulling the timestamp data? (SELECT TIMESTAMPDIFF)
×
×
  • 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.