|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
| View Poll Results: Is really difficult? | |||
| Yes | | 1 | 50.00% |
| No | | 1 | 50.00% |
| Intermediate | | 0 | 0% |
| It is really not | | 0 | 0% |
| Voters: 2. You may not vote on this poll | |||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Table relations
I have two tables which one of them is users and second is reports. I have userID inserted into reports table to personel1, personel2,personel3,personel4,personel5.
I am trying to relate these two tables by sql code as follows; $query3 =mysql_query("SELECT reports.personel1,reports.personel2,reports.person el3, reports.personel4,reports.personel5,users.userID,u sers.userLoginfrom reports,users WHERE $personel1 = users.userID or users.userID = $personel2 or users.userID = $personel3 or users.userID = $personel4 or users.userID = $personel5 AND reports.eventID = '$eventID' "); while ($result3 = mysql_fetch_array($query3)) { echo "<td>"; echo $result3["userLogin"] . "</td>"; } ýt seems OK but here what happens. When I enter a new report with the same $eventID, I see the same personel names twice on the screen. When I run the script with AND instead of OR I see nothing on the screen. Should I do something different , any suggestions? Best Regards |
|
#2
|
||||
|
||||
|
Try wrapping parentheses around all of your ORs to group them:
PHP Code:
I would actually consider putting the personnel data in another table and having a table to join personnel ids to report ids to user ids, but maybe that doesn't suit your needs. |
|
#3
|
|||
|
|||
|
I would strongly recommend what dhouston says...
Use another table to manage the "personel" data.
__________________
The deal is not to know everything, but to know the email of the one who does. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Table relations |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|