0
$event = $_GET['event'];
$id = $_GET['id'];

$stmt = $conn->prepare("SELECT * FROM events WHERE event_name=? AND event_id=?");
$stmt->bind_param("ss", $event, $id);
$stmt->execute();

while($db_data = $result->fetch_assoc()){
    $title = $db_data['event_name'];
    $description = $db_data['event_description'];
    $location = $db_data['event_location'];
    $event_date = $db_data['event_date'];
    $event_time = $db_data['event_time'];
    $end_date = $db_data['end_date'];
}

I am fetching the date from the database, then converting it like so,

$Date = str_replace('/','-',$event_date);
$newDate = date('Y/m/d', strtotime($Date));

However, nothing is displayed on the date input(last input) in the browser when I do this. Note the value $event_date is stored as 2020-02-31 i changed the date's format to YYYY/MM/DD as shown above, the days and months are padded with a 0 and still it doesn't work as suggested here

   <div class='container mt-4 p-4 col-md-6 text-light'>
    <form autocomplete='off' action='update-event.php' method='post'>
    <div class='form-group'>
     <label for='title'>Event Name</label>
     <input type='text' class='form-control' name='event-name' value='".$title."'>
    </div>
    <div class='form-group'>
     <label for='title'>Description</label>
     <textarea class='form-control' name='event-description'>".$description."</textarea>
    </div>
    <div class='form-group'>
    <label for='location'>Event Location</label>
    <input type='text' class='form-control' name='event-location' value='".$location."'>
   </div>
    <div class='form-group'>
    <label for='Event Date'>Event Date</label>
    <input type='date' class='form-control' name='event-date' value='"; echo $newDate; echo"'>
   </div>
  </form>
  </div>
  • 1
    What is this `"; echo $newDate; echo"`? If you are not in PHP already that should be `""`. – Dave Feb 05 '20 at 16:48
  • @harontaiko, please edit your question to add all the code used for the form, otherwise we only can guess how you're doing it. – Triby Feb 05 '20 at 16:52
  • i did that, i hope the question is more clear now – Fifth Horseman Feb 05 '20 at 17:14
  • i used that method but still does not work, am not sure whether its the value from the database itse;f, the format or something wrong with the inout itself – Fifth Horseman Feb 05 '20 at 17:15
  • Turns out, i only need to convert the $event_date value saved in the database as varchar to time by date(strtotime($event_time)) – Fifth Horseman Feb 05 '20 at 18:03
  • *Look At* the HTML that is actually coming out ... look for a typo or something ... does the browser produce any error or warning messages in its logs? – Mike Robinson Feb 05 '20 at 19:20

0 Answers0