I have two tables in my sql database:
Student Table
+—+——-+———–+
|IDl | Name | Status |
+—+——-+———–+
| 1 | Name1 | Active |
| 2 | Name2 | Inactive |
| 3 | Name3 | Pending |
| 4 | Name4 | Dont Know |
| 5 | Name5 | Active |
+—+——-+———–+
and
Info Table
+—+——-+———–+
|ID | GPA | Major |
+—+——-+———–+
| 1 | 3 | CS |
| 2 | 2 | CBE |
| 3 | 3 | CS |
| 4 | 4 | BMS |
| 5 | 2 | CompE |
+—+——-+———–+
so I wan’t to print the name of the people who’s major is CS based on their ID. So in my php code I did this:
$major = mysql_query(“Select ID from Info where Major = ‘CS'”);
$arr = mysql_fetch_array($major);
so $arr now holds the ID of everyone whose major is CS.
Now I want to get their names, but I don’t know how to go through all the ID’s in the $arr.
$names = mysql_query(“Select name from Student where ID = $arr”;
is there a way to do this without changing the tables? thanks.