Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPontus Bolmér
12,471 PointsAdding date to a new post
Im having trouble with something that should be easy enough!
Im working with two textareas, one that shows the result from the database, and you cant edit it, and another box that you write the new messages and it will show up in textbox1.
After every message i want a date to appear!
any ideas? Im stuck!
<form id="NewNotes" name="NewNotes" method="post" action=""> <textarea rows="4" cols="89" name="saveNewNotes" id="saveNewNotes"></textarea> <input type="submit" name="submitnewMessage" value="Spara anteckning"/> <input type="hidden" id="getId" name="getId" value="<?=$_GET['id']?>"> </form> <?php
if(isset($_POST['submitnewMessage'])) {
$message = utf8_decode($_POST['saveNewNotes']);
$customerId = $_GET['id'];
$addDate = date("Y-m-d");
// Sql fråga nästa
$newUpdateNotes = "UPDATE sf_customers SET anteckning = CONCAT(anteckning, :newMessage ) WHERE id=:getId";
$params = [
"newMessage" => $message,
"getId" => $customerId
];
1 Answer
Pontus Bolmér
12,471 PointsWhat do you think about adding my addDate in a concatenated variable?
Im not really sure what you mean tho!
Cris Pijper
11,743 PointsWell, you can do something like this:
$newMessage = "Some new message";
$addDate = date("Y-m-d");
$message = $newMessage . " " . $addDate;
This way you just simply concatenate the date to your new message :)
Cris Pijper
11,743 PointsCris Pijper
11,743 PointsYou could (a) use your $addDate to update your db date column for this new message when you submit your new message, and you could then (b) retrieve this date from the db date column for the corresponding message and (c) echo it with your message