CodeIgniter Forums
Get the value - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Get the value (/showthread.php?tid=66679)

Get the value - Fraps900 - 11-20-2016

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

$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:

$start = '$start_date';
$end = '$deadline';
$diff = (strtotime($end)- strtotime($start))/24/3600;
echo $diff;


Using echo or something?
Thanks for help

RE: Get the value - Wouter60 - 11-21-2016

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.