Hello from Bulgaria, it is my very first post here so excuse me if I do not explain everything very well.
I'm doing admin panel in website(PHP, MYSQL) for Online Language Courses. I have to see:
- A list with all the users registered in the website
- If they are paid or not paid one of the courses ( they are 4 courses at the momment )
- IF they are already input a Promo Code for any of the courses.
The table names and important table column's names are:
- USERS: user_id, email, real_name
- PAID_COURSES: paid_course_id, paid_course_name
- USER_PAID_XREF: xref_id, user_id, paid_course_id
- VOUCHERS: voucher_id, user_id, voucher, paid_course_id
I think the final result must be an array looks like:
array(2)
{
[1]=> array(5) {
["user_id"]=> string(1) "1",
["email"]=> string(15) "email@email.com",
["real_name"]=> string(5) "ANJEL" ,
["paid_course_id"]=> array(4) {
[1]=> string(1) "1"
[2]=> string(1) "0"
[3]=> string(1) "1"
[4]=> string(1) "0"
},
["voucher"]=> array(4) {
[1]=> string(20) "VOUCHER-11111111111"
[2]=> string(1) "0"
[3]=> string(19) "VOUCHER-AAAAAAAAAAA"
[4]=> string(1) "0"
}
}
[2]=> array(5) {
["user_id"]=> string(1) "2"
["email"]=> string(16) "office@email.com"
["real_name"]=> string(5) "MITKO"
["paid_course_id"]=> array(4) {
[1]=> string(1) "0"
[2]=> string(1) "1"
[3]=> string(1) "1"
[4]=> string(1) "0"
},
["voucher"]=> array(4) {
[1]=> string(1) "0"
[2]=> string(20) "VOUCHER-22222222222"
[3]=> string(19) "VOUCHER-BBBBBBBBBBB"
[4]=> string(1) "0"
}
}
}
- [1]=> is the key for user_id
- In the array have 2 additional arrays with length of the number of the paid courses at all (Example at the momment have only 4 paid courses - English, spanish... etc)
- ["paid_course_id"][1]=> the key [1] here is the paid_course_id from paid_courses table
- ["paid_course_id"][2]=> string(1) "1" - The value "1" here is: If there is a row in the table user_paid_xref for the current paid_course_id (in the example paid_course_id=2) is with value 1 if there is not a row then the value is 0 ( With other words the user has paid this course or the user is not paid this course)
- ["voucher"][3]=> string(19) "VOUCHER-BBBBBBBBBBB" - Same here as paid_course_id for a key of the array element.
- ["voucher"][3]=> string(19) "VOUCHER-BBBBBBBBBBB" - The Value here is from table VOUCHERS column's name - voucher
So that's it I hope that someone will understand it. Thanks in advance