Page 1 of 1

[solved] Replacement for "while" loop

Posted: Thu Aug 06, 2015 2:34 am
by thbr02
I'm about to update one of my old vqmods for Opencart 2.0.3.1. It's an extension sending birthday emails to customers. I've managed to update nearly all code, but one thing remains. I can't figure out how to change the while loop in the example below. This is probably a very simple question for experienced programmers, but for a beginner like me it's really hard.

Code: Select all

//Find the customers whose birthday is today
$findCustomers = $this->db->query("SELECT * FROM customer WHERE substr(birth_date,6) = '" . $todayDate . "'");
while($row = mysql_fetch_array($findCustomers)){
   $birthDate = $row['birth_date'];
   $birthEmail = $row['bday_email'];
   $age = $thisYear - (substr($birthDate,0,4));
I would really appreciate any hint how to solve this.

Re: Replacement for "while" loop

Posted: Thu Aug 06, 2015 3:11 am
by chulcha
try it

Code: Select all

$findCustomers = $this->db->query("SELECT * FROM customer WHERE substr(birth_date,6) = '" . $todayDate . "'");
foreach ($findCustomers->rows as $row) {
   $birthDate = $row['birth_date'];
   $birthEmail = $row['bday_email'];
   $age = $thisYear - (substr($birthDate,0,4));

Re: Replacement for "while" loop

Posted: Thu Aug 06, 2015 5:03 am
by thbr02
Wov, it works! Thought it would be easy for a pro :) .

Thanks alot!