2

I'm on PHP JSON query with database.

$qAdzanIqomah = mysqli_query($con, "SELECT * FROM tb_sholat WHERE active = 'Y'");
while($dAdzanIqomah = mysqli_fetch_array($qAdzanIqomah))
{
    $sholatName[] = $dAdzanIqomah['sholat_name'];

    $audio_before_adzan[] = $dAdzanIqomah['audio_before_adzan'];

    $iq = $dAdzanIqomah['iqamah'];

    echo $iqamahC[] = date("H:i:s", strtotime("+ '" . $iq . "' minutes"));
}

$data = array(
    'iqamah' => $iqamahC
);

echo json_encode($data);

The problem is, all the result is same even on table data is variations.

Result echo $iqamaC[]:

{"iqamah":["01:00:00","01:00:00","01:00:00","01:00:00","01:00:00"]}

-

01:00:00
01:00:00
01:00:00
01:00:00
01:00:00

Result echo $iq:

11
12
17
13
10

Is there something wrong with that code?

1 Answer 1

3

You have unnecessary quotes and spaces in the minute-adding code, and that is the actual cause of the issue (failing to add minutes)

Remove unnecessary quotes like below:-

$iqamahC[] = date("H:i:s", strtotime("+$iq minutes"));

And check.

A demo working example:-https://eval.in/891471

Sign up to request clarification or add additional context in comments.

1 Comment

@HiDayurieDave glad to help you :):)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.