2014-05-06 13:34


  • php
  • mysql

I have two tables - Utilizadores and Competencias.

NOTE: Utilizadores = Users And Competencias = Skills

Each user can have 1 or more Skills.

I need to print them in a dropdown menu, where, for each skill, it shows the user that has that skill.

So, SKILLS->USER THAT HAS THE SKILL (The visual is all done, but it doesn't work properly - Explained next)

Here is the first query:

$query2 = mysql_query("SELECT DISTINCT competencias, id_user FROM ce");
$ut = array();
while ($result = mysql_fetch_array($query2)) $ut[] = $result;
foreach ($ut as $u){

(Nevermind the number 2 on the query2.) This query searches in the table "Skills" the id of the user that contains that specific skill. Again, A user can have more than just 1 skill.

Second Query:

$query3 = mysql_query("SELECT `id`, `nome` FROM utilizadores WHERE id='$id_user'");
$utt = array();
while ($result2 = mysql_fetch_array($query3)) $utt[] = $result2;
foreach ($utt as $utilizador){

This Second Query searched on the table "Users" for the names of the users

Anf finaly, the third part:

foreach ($ut as $hu){
echo "<li class='has-sub'><a><span>" .$hu[0]. "</span></a>";
    echo "<ul><a href='php/curriculo.php?nomeut=$nomeuser'>". $nomeuser. "</a></ul>";

Now the problem I'm Having: When the mouse overs the skill present on the dropdown menu, it shows a sub-dropdown showing only the name of the user that contains the skill. But it always shows me the same name.

In the database, Several Skills belong to Several Users, but, on the sub-dropdown, it shows the name of ONE person only, instead of the ones corresponding to their skill.

Let's say:
John has a skill "Sharepoint"
Smith has a skill "Whatever"

When i pass the mouse on "Sharepoint" ->John
When i pass the mouse on "Whatever" -> John - When it really corresponds to "Smith".

I am sorry for the realy long problem, and for my awful english.

Any help is appreciated
Thanks :)

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享