| | |
Im really really stuck ....
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
Join Date: Dec 2007
Posts: 136
Reputation:
Solved Threads: 2
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
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
•
•
Join Date: Oct 2008
Posts: 3
Reputation:
Solved Threads: 0
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!
.... 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!
I think what you are saying is you want to loop through all database results from both queries, try this:
php Syntax (Toggle Plain Text)
<?php $debug = false; //set to false if not debugging script echo $debug?$query . "<br />":""; //if in debug, display query print "$openHTML"; $query = "SELECT * FROM job_roles WHERE user_id = '$username'"; $findresult = mysql_query($query); while($find_access = mysql_fetch_assoc($findresult)) { $query = "SELECT * FROM job_positions WHERE name = '".$find_access['job_id']."'"; $find_job = mysql_query($query); echo $debug?$query . "<br />":""; //if in debug, display query $counter = 0; while($row = mysql_fetch_array($find_job)) { if($debug) //if in debug, dump array content to browser { var_dump($row); echo "<br />"; } if((int)$row[lobby] > 0) { $counter++; } switch((int)$row['lobby']) { case 1: echo "show content gere for access level 1"; break; case 2: echo "show content gere for access level 2"; break; case 3: echo "show content gere for access level 3"; break; case 4: echo "show content gere for access level 4"; break; case 0: echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!"; break; default: echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!"; break; } } } echo $counter == 0?"<p><br><p><p><center>This page is a restrcited area. You do not have access!":""; print "$closeHTML"; ?>
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.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
Join Date: Dec 2007
Posts: 136
Reputation:
Solved Threads: 2
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)
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)
PHP Syntax (Toggle Plain Text)
$find_access = mysql_query("SELECT user_id,lobby,shops FROM job_roles,job_positions WHERE job_roles.job_id = job_positions.id"); print "$openHTML"; $find_job = fetch("SELECT * FROM job_positions WHERE name = '$find_access[job_id]'"); $counter = 0; while($row = mysql_fetch_array($find_access)) { if ( ($row[lobby]== 1) AND ($row[user_id] == $username)) { echo "show content gere for access level 1"; $counter++; } if ( ($row[lobby]== 2) AND ($row[user_id] == $username)) { echo "show content gere for access level 2"; $counter++; } if ( ($row[lobby]== 3) AND ($row[user_id] == $username)) { echo "show content gere for access level 3 "; $counter++; } if ( ($row[lobby]== 4) AND ($row[user_id] == $username)) { echo "show content gere for access level 4"; $counter++; } if ( ($row[lobby]== 0) AND ($row[user_id] == $username)) { echo "<p><br><p><p><center>Sorry but your Access Level is not permitted for this page!"; $counter++; } } echo $counter == 0?"<p><br><p><p><center>This page is a restrcited area. You do not have access!":""; print "$closeHTML";
![]() |
Similar Threads
- Windows XP is stuck! (Windows NT / 2000 / XP)
- Advertisment icons stuck to my desktop!!! (Viruses, Spyware and other Nasties)
- Stuck writing a Function (C++)
- error message when shutting down, startup page stuck to http://dr-search4u.com/ind... (Viruses, Spyware and other Nasties)
- Stuck In Restart Loop (Windows NT / 2000 / XP)
- Help with Class, stuck. (C++)
- CPU use stuck at 100% (Viruses, Spyware and other Nasties)
- Stuck on start up (Windows NT / 2000 / XP)
- Internet explorer 5 gets stuck (Web Browsers)
- stuck in lower case, lost functions (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Problem with auto profile generator
- Next Thread: Empty a table?
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable variables video web youtube





