gtal3x Posted December 7, 2007 Share Posted December 7, 2007 Ok i got 1200 users in my db and i wont to display all of them in many pages by 250 on each page... Not only this but i wont to display the target users(the important users) on top of the page. The problem i have is that when i am trying to load the page in 90% the page wont come up instead will come up blank page in netscape and "Page cannot be displayed" in ie. I have the same script seans i started this project and it was working fine when i had 4000 users. When the number raised to 8000 i started having this problem, but few refreshes would usually solve the problem, now i have 1200 users and i have to keep clicking the refresh button for like 20 minutes so the page finnaly displays... I believe the problem must be because the script reaches the time limit... because i got 2 whiles inside for mysql_fetch_array witch both accesses the 1200 rows. One while to get the users that are targets and the second while is to get all the users. You may ask why i did that in two whiles, i could simply do this in one while: if ($user == "target") { $print_targets .= $user; } else { $print_users ........... AND SO ON However i cant do this because i need one while to get result from all users and the second one is limited by 250 (so its only displays 250 users on each page) here is my code: $site_rows = mysql_query("SELECT login FROM $sitename"); $site_users = mysql_num_rows($site_rows); $site_rows2 = mysql_query("SELECT login FROM $sitename ORDER BY time DESC LIMIT $offset, $rowsPerPage"); $sitetitle = str_replace("_",".",$sitename); while ($row = mysql_fetch_array($site_rows)) { $user = $row['login']; $target_rows = mysql_query("SELECT login FROM target_users WHERE site = '$sitename' AND login = '$user'"); $target_user = mysql_fetch_array($target_rows); if ($target_user) { $print_t_users .= "<a href=\"admin.php?page=userdetails&sitename=$sitename&user=$user\">$user</a>, \n"; } } while ($row = mysql_fetch_array($site_rows2)) { $user = $row['login']; $print_users .= "<a href=\"admin.php?page=userdetails&sitename=$sitename&user=$user\">$user</a>, \n"; } Thanks for any help in advance! Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 *bump Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 Use page pagination so you're only pulling 250 at a time instead of all 1200. It will take some programming, but worth it in the end... PhREEEk Link to comment Share on other sites More sharing options...
boushley Posted December 7, 2007 Share Posted December 7, 2007 And for the lazy way... if you have access the the php.ini increase the max execution time. But PhREEEk's suggestion really would be the better. And can you not simply put a LIMIT 250 on you QUERY? Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 Use page pagination so you're only pulling 250 at a time instead of all 1200. It will take some programming, but worth it in the end... PhREEEk You dident read my post propely, thats exacly what i am doing And for the lazy way... if you have access the the php.ini increase the max execution time. i dont have access to php.ini Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 you went on about the execution time changing as your user number changed over time. If you are only pulling 250 per time, how does it matter how many total there are?? That's why I assumed... I didn't improperly read... PhREEEk Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Sounds like he's pulling all the data and only displaying 250, instead of limiting his data query to just 250 at a time. Link to comment Share on other sites More sharing options...
boushley Posted December 7, 2007 Share Posted December 7, 2007 SQL has the LIMIT function... you would want LIMIT 0, 249 (the first page...) then LIMIT 250, 499 (for the second page...) Then you'll only be pulling 250 records from the database... and php won't have to loop over them all. Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 I explained exacly what i need, I have 2 whiles. 1 while is to search from all the 1200 users, and display ONLY the target users (witch are only 8-10). The second while is limited by 250 so its displays the first 250 of all my users. I believe the problem is because i am using 2 whiles on the same script... But i need both results on the same page... Any idea how to do this a diffrent way? $site_rows = mysql_query("SELECT login FROM $sitename"); $site_users = mysql_num_rows($site_rows); $site_rows2 = mysql_query("SELECT login FROM $sitename ORDER BY time DESC LIMIT $offset, $rowsPerPage"); $rowsPerPage = 250 So Yes i am limiting the results Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 What determines a "target user"? Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 What determines a "target user"? I have all site users on one table, on another table wich is called target_users (the importent users) i have like 10 rows... So basicly i search in the 1st while if i have got the same user in both tables then display them... the second while is just to print 250 first users from all 1200. I am explaining everything over and over again... Is my english that bad and no one can understand me? EDIT: And i am not forcing anyone to help me, i am always thankfull to people just for reading my posts, but at least try to understand what i am trying to do Thanks a lot again! Link to comment Share on other sites More sharing options...
jacksonmj Posted December 7, 2007 Share Posted December 7, 2007 The problem is that you are retrieving all of the usernames using your first MySQL query ("SELECT login FROM $sitename"). You are then using PHP to get the right ones from that list. This is a slow way to do it. Using one MySQL statement to select and return the target rows would be much faster. Something like this would perhaps work: $target_rows = mysql_query("SELECT login FROM $sitename, target_users WHERE $sitename.login = target_users.login"); $site_rows2 = mysql_query("SELECT login FROM $sitename ORDER BY time DESC LIMIT $offset, $rowsPerPage"); $sitetitle = str_replace("_",".",$sitename); while ($target_user = mysql_fetch_array($target_rows)) { $user = $target_user['login']; $print_t_users .= "<a href=\"admin.php?page=userdetails&sitename=$sitename&user=$user\">$user</a>, \n"; } while ($row = mysql_fetch_array($site_rows2)) { $user = $row['login']; $print_users .= "<a href=\"admin.php?page=userdetails&sitename=$sitename&user=$user\">$user</a>, \n"; } Using the database engine to select the required rows is usually much faster than doing it with PHP. Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 jacksonmj: Thanks for reply i understood what you mean... however i am getting the above error: Column 'login' in field list is ambiguous What does ambiguous mean? and how to solve it? Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 I am explaining everything over and over again... Is my english that bad and no one can understand me? No, your English is just fine. You're rude is all. No problem. Best of luck with your issue. PhREEEk Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 I am explaining everything over and over again... Is my english that bad and no one can understand me? No, your English is just fine. You're rude is all. No problem. Best of luck with your issue. PhREEEk Completly disagree. I mentioned that i am paging all my results on pages by 250 on each at least 2-3 times in my post, and say for example you wasnt reading what i was saying... What about the code: $site_rows2 = mysql_query("SELECT login FROM $sitename ORDER BY time DESC LIMIT $offset, $rowsPerPage"); And then you just post thats i sould do the paging thing... Anyway i dont wonna discuss this further... Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 Friend, you must be INSANE... I advised to go with pagination after your first post. Your posting of code showing limits was your 3rd post. I doubt there's much argument... we are here, in this thread, it is right there in the chronological order it happened in. You know... YOU came here seeking help or advice. You keep telling us we must listen to you, yet you are not reciprocating by keeping an open mind with our thoughts on the problem. You seem to know exactly how you want it solved, yet are unable to solve it yourself. I have no idea what further value we offer each other, so I will move on to other people who will be willing to try our suggestions rather than to act like we are wasting their time by trying to help them. Good day. PhREEEk Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Go to MYSQL website and look for reserved words. jacksonmj: Thanks for reply i understood what you mean... however i am getting the above error: Column 'login' in field list is ambiguous What does ambiguous mean? and how to solve it? Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 Friend, you must be INSANE... I advised to go with pagination after your first post. Your posting of code showing limits was your 3rd post. I doubt there's much argument... we are here, in this thread, it is right there in the chronological order it happened in. You know... YOU came here seeking help or advice. You keep telling us we must listen to you, yet you are not reciprocating by keeping an open mind with our thoughts on the problem. You seem to know exactly how you want it solved, yet are unable to solve it yourself. I have no idea what further value we offer each other, so I will move on to other people who will be willing to try our suggestions rather than to act like we are wasting their time by trying to help them. Good day. PhREEEk Man you are either blind or you smoke too much crack... Here is your comment: I advised to go with pagination after your first post. Your posting of code showing limits was your 3rd post. I doubt there's much argument... And here is my original post: Ok i got 1200 users in my db and i wont to display all of them in many pages by 250 on each page... . . . However i cant do this because i need one while to get result from all users and the second one is limited by 250 (so its only displays 250 users on each page) here is my code:....................... So why are you lying then? I posted clearly that i already display 250 users on each page. I have seen many of your posts, in most of them you dont even read a problem and you just post your answer straight away and in some of them you are complitly rude and offer no help... I dont know why are you doing this... mybe because you just wont to increase your rating by posting stupid replys? I have to agree that i help rarely on this forum and most of the times i am asking for help, this is because there are so many questions here that i cannot answer (my php levels is not that good), so i just dont answer them, and i guess i dont have the same problem with rating like you do so i dont need just to post nonesances... Now you have a good day Link to comment Share on other sites More sharing options...
jacksonmj Posted December 7, 2007 Share Posted December 7, 2007 Sorry, slight mistake, first line of code should have read: $target_rows = mysql_query("SELECT $sitename.login FROM $sitename, target_users WHERE $sitename.login = target_users.login"); Searching for the error message text is usually helpful when trying to solve errors (in this case, a summary of how to fix the problem came up on the first Google search results page). Ambiguous means that it is not clear exactly what is meant. In this case, there are two tables each with a 'login' column, and MySQL is unsure which table you want it to get the value from. In queries where more than one database table is used, the correct table should always be specified every time a column name is used. Hence changing "SELECT login" to "SELECT $sitename.login" in the query should fix the problem. Link to comment Share on other sites More sharing options...
gtal3x Posted December 7, 2007 Author Share Posted December 7, 2007 Sorry, slight mistake, first line of code should have read: $target_rows = mysql_query("SELECT $sitename.login FROM $sitename, target_users WHERE $sitename.login = target_users.login"); Searching for the error message text is usually helpful when trying to solve errors (in this case, a summary of how to fix the problem came up on the first Google search results page). Ambiguous means that it is not clear exactly what is meant. In this case, there are two tables each with a 'login' column, and MySQL is unsure which table you want it to get the value from. In queries where more than one database table is used, the correct table should always be specified every time a column name is used. Hence changing "SELECT login" to "SELECT $sitename.login" in the query should fix the problem. Man if i was a modarator i would change your rank from n00bie to super guru! Thanks a lot for your help thats excacly what i needed! Finally someone understood my question TOPIC SOLVED Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 8, 2007 Share Posted December 8, 2007 I am going to have to insist that you STOP trying to reverse what went on here... You accuse me of lying, yet I was respinding directly to this: Completly disagree. I mentioned that i am paging all my results on pages by 250 on each at least 2-3 times in my post, and say for example you wasnt reading what i was saying... What about the code: $site_rows2 = mysql_query("SELECT login FROM $sitename ORDER BY time DESC LIMIT $offset, $rowsPerPage"); And then you just post thats i sould do the paging thing I am NOT lying by stating it didn't happen this way, because it didn't. You posted that code AFTER I suggested pagination, so saying that I suggested it AFTER you provided the code makes YOU the confused party here. The proof is in the thread order. Read it and whine some more... What is actually accurate here, is that I suggested doing pagination after you mentioned something about 250 results per page. I have obviously not adequately conveyed my reason for doing this, so let's go over the information you posted FIRST, right before I recommended pagination. For the record, you gave us these facts to work with: You have 1200 users, and you want to display them 250 per page ref: Ok i got 1200 users in my db and i wont to display all of them in many pages by 250 on each page... You do not state that you are CURRENTLY doing this, you are saying you WANT to do this, this is your goal. Your project ran FINE when you had 4000 users When the number reached 8000 is when you started having problems Now you have 1200 users and it has become a disaster that has to be fixed ref: it was working fine when i had 4000 users. When the number raised to 8000 i started having this problem, but few refreshes would usually solve the problem, now i have 1200 users and i have to keep clicking the refresh button for like 20 minutes so the page finnaly displays... The obvious question is not do we have a language barrier, but whether or not we have a mathematical barrier. Logic would dictate that if 4000 is good, 8000 bad, then 1200 should not be a problem. By the way, what happened to 6800 users...? You then state that the problem is because you have a while loop inside another while loop. You give us an example of how you could have done it with ONE while loop, but the example you provide is an IF condition...? ref: One while to get the users that are targets and the second while is to get all the users. You may ask why i did that in two whiles, i could simply do this in one while: if ($user == "target") { $print_targets .= $user; } else { $print_users ........... AND SO ON So, finally, you say that one while retrieves ALL 1200 records, and the second one retrieves 250 at a time to display 250 per page. I suggested going with pagination because you provided NO CODE what so ever that shows us how your '250 per page' is actually working, nor any SQL querys. You are stating fact that the number of users causes you vastly differing results, and as I had stated, if you are TRULY only pulling 250 at a time, it shouldn't matter what the total number of users is. I concluded that your pagination was probably not setup right, so that's why I suggested investigating that option. That was my ONLY contribution towards a fix to your problem, and the above is ALL YOU PROVIDED for us to work with. Several responders behind me agreed, so they were obviously not confident your pagination was setup correctly either. THEN, you come back and show us your query. Now it becomes apparent where the bottleneck is, yet you contend I am some CRACK HEAD for suggesting proper pagination up front? Talk about Monday morning quarterbacking! (US football reference... don't stress over it). Everyone attempting to help at first was convinced that the pagination was not setup correctly, and we were ALL correct. Part of PROPER PAGINATION is PROPER selection of the data from MySQL, and that was were your problem ended up being. Last thing I'll address is your personal stab at me: I have seen many of your posts, in most of them you dont even read a problem and you just post your answer straight away and in some of them you are complitly rude and offer no help... I dont know why are you doing this... mybe because you just wont to increase your rating by posting stupid replys? I am one of the FEW contributors here who takes the time the time to explain a lot of the code I provide. I quite often post small tutorials so that the OP actually learns something from the code provided. I take a great amount of pride in the help that I provide back here. If you want to look at my contributions here at PHP Freaks with negative colored lenses and only see those results, then your ability to see overall results in people equals your skill at getting good results with your querys. I have written WHOLE scripts for several users here, from SCRATCH, and received not a PENNY in compensation. But they provided what you didn't.. good attitude, patience, and a feeling of appreciation for my time. I am never RUDE to people, but I can be short with those who do not make any attempt at helping themselves. We who provide code are NOT your bitches. We do this for the majority who appreciate it, and I welcome idgits like who who expose themselves as the ungrateful malcontents that they are, because we will avoid wasting our time on you in the future. It's just good to get these things out of the way as soon as possible. Your social skills are extremely questionable, if not directly hazerdous to your future health. While I know a lot of you punks think you're tough behind a monitor, eventually you'll make the mistake of calling someone a crack smoker to their face. If you survive the ass beating you'll receive, then you'll hopefully realize that the other human beings sharing oxygen with you on this planet are not your door mats. PhREEEk Link to comment Share on other sites More sharing options...
gtal3x Posted December 8, 2007 Author Share Posted December 8, 2007 How many lines did you post now? You can write a book if u continue like that. To be honest i cant be even bothered to read all this crap, take it this way, i don't like reading books. If someone is crazy enough to read all this then please post a brief description of what he was trying to say... And something last, why are you trying so hard to cover up what happened? You think if you write 1000 lines everyone is gonna read them and by the time they finish they will forget the hole point and just leave? Simple solution, dont pass your bullshit to users, and let them decide for them self who is right and who is wrong (if they can be bothered)... Agree? If you would have putted as much effort to my thread as you putted to write all this nonsenses, you would probably had answered it in 30 seconds, You remind me of someone who says so much bullshit and never does anything... Take a simple example of jacksonmj, he just gave 1-2 minute(s) to read and understand my post and then came up with a right solution If you simply dont know the answer to the question dont answer, or if you dont get what i mean then say WDF DO YOU MEAN THERE, dont just post anything you can think of just to say you posted. And the really last thing... I dident ask for your help at all, I asked help from people that are willing to help or at least give a right advice (after they understand the problem NOT before) and i know this forum is full of people like this, they really trying to help, and if i get the chance i will do anything to help them is well! EDIT: By the way i got NO problem at all because you dident understand my post, many other dident understood it either for some unknown reason (maybe its my fault btw!). The problem started when you start calling me rude and other things and when you tryed convince me that i cant remember what i wrote in my own post and how you are the top boy in the team and bla bla bla Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 8, 2007 Share Posted December 8, 2007 >take it this way, i don't like reading books. I'm trying to figure out why that isn't surprising... I can't. >please post a brief description of what he was trying to say... I'd be happy to, my mentally handicapped lil' friend! I'll also do you the favor of typing it very slow, so you can more easily follow along... Part of PROPER PAGINATION is PROPER selection of the data from MySQL' date=' and that was where your problem ended up being.[/quote'] >maybe its my fault btw! Yeah, you get it. You're just being a prick for the sake of it, since that's your basic personality. Next time you fail to explain your problem well enough the first time, as well as provide the actual RELEVANT code, don't be RUDE to responders and tell them they don't read properly. As for your childish attempt at comparing jacksonmj with any other contributor around here... he didn't 'solve' your problem based on your first post. He saw the solution after you decided to grace us with the actual RELEVANT code 2 posts later. Several others, including myself, saw the same error, but decided to not help you after you sniped some crass-ass remark about being tired of explaining over and over again (and which part were you tired of explaining over and over to us? The part about the problem was a nested while loop? ). Oh damn, it's becoming a book again! You reveal everything anyone needs to know about you before they attempt to help you in the future. For example, jackson made a 'slight mistake' that generated you an error. So what do you do to help yourself? Do you research a clear error message and try to figure out why it's there? Nope... you RUN back here as fast as possible and: jacksonmj: Thanks for reply i understood what you mean... however i am getting the above error: Column 'login' in field list is ambiguous What does ambiguous mean? and how to solve it? LOL... how sad to be so inept and helpless... Even your new hero Guru jackson scolded you, telling you that the answer was the first result that comes up in Google... but you cannot be bothered, right? You expect the answer(s) to be provided to you. It is your birth right or some shiz... PhREEEk Link to comment Share on other sites More sharing options...
gtal3x Posted December 8, 2007 Author Share Posted December 8, 2007 For example, jackson made a 'slight mistake' that generated you an error. So what do you do to help yourself? Do you research a clear error message and try to figure out why it's there? Nope... you RUN back here as fast as possible and: Quote from: gtal3x on Yesterday at 02:09:14 PM jacksonmj: Thanks for reply i understood what you mean... however i am getting the above error: Code: Column 'login' in field list is ambiguous What does ambiguous mean? and how to solve it? LOL... how sad to be so inept and helpless... Even your new hero Guru jackson scolded you, telling you that the answer was the first result that comes up in Google... but you cannot be bothered, right? You expect the answer(s) to be provided to you. It is your birth right or some shiz... jackson was 100% right when he told me that i could search google, Just so you know after hes script dident work i was about to search a google myself, instead of doing this however i was siting here and having an argument with one little bitch. You. I assume that all you trying to do in your posts is to show how well educated and smart you are, and you even tryed to snick the idea that i cant understand what your are saying and you have to write more slowly... Well so you just stop trying to show off ill tell you that we all speak english here, however we dont all leave in usa and we dident all finish the Barkley university, and just because i do few simple typos in my sentences and i am strugling to understand your literature english doesnt mean i am uneducated, just so you know i speak and write in 3 complitly different languages, i know 2 of them perfectly and 1 just good wich is english Anyway stop writing your cheap propaganda to the solved topic the topic is solved just get it! I dont wonna continue this stupid conversation with you, i have got my opinion, u have got yours. For me the problem is solver... However if you still feel like you have a personal problem with me, then PM me, i would be happy to provide you with my mobile number and where i live, and we can start from there to solve your problem. Link to comment Share on other sites More sharing options...
redbullmarky Posted December 8, 2007 Share Posted December 8, 2007 that's enough. topic locked. Link to comment Share on other sites More sharing options...
Recommended Posts