My problem is that the database fields have been badly designed by previous people before me. We are accessing the table rows horizontally.
I am working with PHP and jQuery right now and I am passing data back and forth through AJAX. In PHP I am accessing this array like so:
$attendance['date_lesson_' . $lessonCount]
where lessonCount is a number from 1-10 that is incremented i.e. if lessonCount = 1
then above would be $attendance['date_lesson_1']
I am passing the attendance array through json_encode
How do I therefore access this field data_lesson_
1 up to 10 in jQuery?
I am trying to do:
var lessonCount = 1;
attendance[i].date_lesson_+lessonCount
//do some stuff with attendance.date_lesson_
lessonCount++;
It was easy in PHP cause you concatenate strings with the dot "."
but this isn't a string I'm dealing with in jQuery/JavaScript so how on earth would I do this?
Yes, I know. This is awkward. I agree 100%.
You’ll need to use bracket notation:
attendance['date_lesson_' + lessonCount]
Dot notation can only be used with identifier names as property names.
Just a guess, I don't know how that json looks like.
attendance["date_lesson_"+lessonCount]