Automatically add date to database table when button clickde
Posted: Fri Apr 12, 2013 12:51 pm
Adding Assessment Form PHP
In my Assessment table in the sql database[/quote]
<?php $con=mysqli_connect("localhost","root","","User_db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM Assessments"); echo "<table border='0' cellpadding='40' cellspacing='0'> <tr> <th>Title</th> <th>Lecturer</th> <th>Start</th> <th>Due</th> <th>Completed</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Title'] . "</td>"; echo "<td>" . $row['Lecturer'] . "</td>"; echo "<td>" . $row['Start'] . "</td>"; echo "<td>" . $row['Due'] . "</td>"; echo "<td>" . $row['Completed'] . "<form action='' align='center'> <input type='checkbox' name='Completed' value='Completed'/><br/> <input type='submit' name='Completed' value='Completed'/> </form></td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?>Inserting Assessments to table
<?php $con=mysqli_connect("localhost","root","","User_db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $strCompleted = $_POST['Completed']; if ($strCompleted == "Completed") { $strCompleted = "NOW()"; } else { $strCompleted = ""; } $sql="INSERT INTO Assessments (Title, Lecturer, Start, Due, Completed) VALUES ('$_POST[Title]','$_POST[Lecturer]','$_POST[Start]','$_POST[Due]','$strCompleted')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error()); } header( "Location: Assessment_Calendar.php" ) ; mysqli_close($con); ?>Hi guys I was wondering if, using JQuery or anything possible, I could could click on the "Completed" button and it would check the date on which it was created and it would enter that detail in the "Completed" column
In my Assessment table in the sql database[/quote]