Jump to content

[SOLVED] Obtaining a date from a database?


lokie538

Recommended Posts

Hi,

 

I have a form that I need to display a date from a mysql server. How do I make it that a date is pulled out shown on the form and make that the date is changeable and then when its changed, update the original date in the database. At the moment I can pull out a date, show it on a form (in a text box) but when the value is changed in the text box there is an error when It is submitted.

 

So how do I make a date changeable on the form and able to be put back in the mysql database?

 

Thanks in advance,

Lokie538

Link to comment
https://forums.phpfreaks.com/topic/103962-solved-obtaining-a-date-from-a-database/
Share on other sites

///////////////////// query (i know this works)
$query4 = "SELECT * FROM `enrolmentreview` where ID ='" . $_POST['id'] . "'";
$result4 = mysqli_query($cxn,$query4) or die ("Couldnt execute queryrow4.");
$row4 = mysqli_fetch_assoc($result4);

////////////////////// form
<p>Contact Date:
              <input name="contactdate" type="text" id="contactdate" value="<?php echo $row4[ContactDate] ?> ">
            </p>

///////////////////// the next info is on the save page:


$query2 = "UPDATE studhpe1 SET Date_Enrolled='" . $_POST[date1] . "' WHERE ID ='" . $_POST[id] . "'";
$result2 = mysqli_query($cxn,$query2) or die (mysqli_error ());

1 ) I assume the id is stored in in a field in the form so it gets posted to save page

 

2 ) The date input field name is "contactdate" in the form but "date1" in the update query

 

3 ) You said there is an error. What is the error message?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.