Im really really stuck ....

Reply

Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Im really really stuck ....

 
0
  #21
Oct 13th, 2008
Originally Posted by justted View Post
Ah ok thanks.

Ive never done that query database manager thing and gave it a go. It showed me the job_roles table with all rows.

:>/
So are you looking to loop through all the rows from the only the second query and the first as well? And did the script actually loop through all the data as you were expecting, probably not huh?
Last edited by R0bb0b; Oct 13th, 2008 at 8:47 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 136
Reputation: justted is an unknown quantity at this point 
Solved Threads: 2
justted justted is offline Offline
Junior Poster

Re: Im really really stuck ....

 
0
  #22
Oct 13th, 2008
nope!
lol it didnt.

I dunno what im doing now. Got myself all confused.

I thought using the IF statement with else if for each level.

So it would check IF job position equals to 1 in the lobby field then show this ....

elseif the job position equals to 2 in the lobby field then show this .... and so on. That way it would have first checked to see if that member has a level one job then if not to see if they have a level 2 job and so on.

Arrghh ... lol
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Im really really stuck ....

 
0
  #23
Oct 13th, 2008
run it with the $debug on and post the results.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: gamn44 is an unknown quantity at this point 
Solved Threads: 0
gamn44 gamn44 is offline Offline
Newbie Poster

positions allocated to that member and

 
0
  #24
Oct 14th, 2008
The problem is that for some reason it will only return 1 result of jobs for the user. I want to be able to allocate more than one position to my admins and therefore have the code find all job positions allocated to that member and then allow the highest level.

.... so say for example ... one admin has the job position of technical support and moderator! Tech support is level 1 (highest) and moderator is level 4! By using this method the code only seems to pick up the first job allocated to that member in the database and wont check all job positions!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Im really really stuck ....

 
0
  #25
Oct 14th, 2008
I think what you are saying is you want to loop through all database results from both queries, try this:
  1. <?php
  2. $debug = false; //set to false if not debugging script
  3.  
  4. echo $debug?$query . "<br />":""; //if in debug, display query
  5.  
  6. print "$openHTML";
  7.  
  8. $query = "SELECT * FROM job_roles WHERE user_id = '$username'";
  9. $findresult = mysql_query($query);
  10. while($find_access = mysql_fetch_assoc($findresult))
  11. {
  12. $query = "SELECT * FROM job_positions WHERE name = '".$find_access['job_id']."'";
  13. $find_job = mysql_query($query);
  14. echo $debug?$query . "<br />":""; //if in debug, display query
  15.  
  16. $counter = 0;
  17. while($row = mysql_fetch_array($find_job))
  18. {
  19. if($debug) //if in debug, dump array content to browser
  20. {
  21. var_dump($row);
  22. echo "<br />";
  23. }
  24.  
  25. if((int)$row[lobby] > 0)
  26. {
  27. $counter++;
  28. }
  29.  
  30. switch((int)$row['lobby'])
  31. {
  32. case 1:
  33. echo "show content gere for access level 1";
  34. break;
  35. case 2:
  36. echo "show content gere for access level 2";
  37. break;
  38. case 3:
  39. echo "show content gere for access level 3";
  40. break;
  41. case 4:
  42. echo "show content gere for access level 4";
  43. break;
  44. case 0:
  45. echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!";
  46. break;
  47. default:
  48. echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!";
  49. break;
  50. }
  51. }
  52. }
  53.  
  54. echo $counter == 0?"<p><br><p><p><center>This page is a restrcited area. You do not have access!":"";
  55. print "$closeHTML";
  56.  
  57. ?>
Last edited by R0bb0b; Oct 14th, 2008 at 6:38 am.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 136
Reputation: justted is an unknown quantity at this point 
Solved Threads: 2
justted justted is offline Offline
Junior Poster

Re: Im really really stuck ....

 
0
  #26
Oct 14th, 2008
Heya .... sorry for the dealy. I have got somewhere but still have a slight issue!

The code is now working but is of course showing results for all access levels when all I want is one result!

I had a think about it all and worked out the problem was with the initial variables. Because I have the 2 tables that I need to retrieve info from and need to create a variable for that...it was still only getting one result.

So I have searched and found out you can create a JOIN to select the information from 2 tables and basically make it one variable.

So now the code works but returns all results for each access level. This would obviusly look a mess and so I need to work out how to make it so it only returns the results for level 1 access first ... then if no level 1 access check and return results for level 2....and if none then to continue!

:>/ Any Ideas? im just going to have a play and see what i can come up with! :O)

Thanks for all your help. :O)

  1.  
  2. $find_access = mysql_query("SELECT user_id,lobby,shops FROM job_roles,job_positions WHERE job_roles.job_id = job_positions.id");
  3.  
  4. print "$openHTML";
  5.  
  6. $find_job = fetch("SELECT * FROM job_positions WHERE name = '$find_access[job_id]'");
  7. $counter = 0;
  8. while($row = mysql_fetch_array($find_access))
  9. {
  10. if ( ($row[lobby]== 1) AND ($row[user_id] == $username))
  11. {
  12. echo "show content gere for access level 1";
  13. $counter++;
  14. }
  15. if ( ($row[lobby]== 2) AND ($row[user_id] == $username))
  16. {
  17. echo "show content gere for access level 2";
  18. $counter++;
  19. }
  20. if ( ($row[lobby]== 3) AND ($row[user_id] == $username))
  21. {
  22. echo "show content gere for access level 3 ";
  23. $counter++;
  24. }
  25. if ( ($row[lobby]== 4) AND ($row[user_id] == $username))
  26. {
  27. echo "show content gere for access level 4";
  28. $counter++;
  29. }
  30.  
  31. if ( ($row[lobby]== 0) AND ($row[user_id] == $username))
  32. {
  33. echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!"; $counter++;
  34. }
  35. }
  36.  
  37. echo $counter == 0?"<p><br><p><p><center>This page is a restrcited area. You do not have access!":"";
  38. print "$closeHTML";
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC