You should check the manual of mysql, so, as far as you explain u should create the query for two tables... you can use the procedures of mysql to get results.. u can always use a foreach to read all values, and if u want an specific kind of array you can create it meanwhile the loop is running through your object/array returned by mysql
I think if you create an array (like i think u want to create) with the form (name, courseid, courseid, courseid) u might get a mess with all the data, and might create an array per user. I think the best is to recieve the objects or arrays that u get from the query.
for the query, assuming you have an associative field, you can do something like this
select * from user, courseAttrs where user.courseattr = courseattr.id_couse_attr
If you use mysql_fetch_object
while ($row = mysql_fetch_object($result)) {
echo $row->user_id;
echo $row->fullname;
}
mysql_fetch_assoc() returns associative array:
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
}
mysql_fetch_array() returns array
while ($row = mysql_fetch_array($result)) {
echo $row[0];
echo $row[1] ;
}
courseAttrentries and the second one has 4 then the query would return 6 rows, each with a different courseID but not comma separated. I could handle this with PHP but I am assuming there is a simpler solution through MYSQL. I have the feelingJOIN ONcould help but I don't know how theJOINcommand works.