• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get the value

#1
Hi guys, please tell me how to get the value form these below dates:

Code:
$sql = "SELECT start_date, deadline FROM projects WHERE id =7";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        [b] echo $row["start_date"];[/b]
        [b] echo $row["deadline"];[/b]
    }
}


to this:

[code]
<?php
$start = '$start_date';
$end = '$deadline';
$diff = (strtotime($end)- strtotime($start))/24/3600;
echo $diff;

?>



Using echo or something?
Thanks for help
Reply

#2
There's no need for a "foreach ..." structure if the result can only be one row (where id=7 will only return 1 row, right?).
Why do you ask this question in a CodeIgniter forum? None of your code proves that you use CodeIgniter in any way.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.