Pls Help With This Php Program - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Pls Help With This Php Program (921 Views)
| Pls Help With This Php Program by shokergb(op): 5:12pm On Jan 11, 2011 |
I am trying to iterate over a select query with a while loop and that will terminate the loop when it gets to a specified number.but the program is not iterating,i would appreciate your help.the code is shown below $count=0; while($count<3){ if(name[$count] != null){ $selectquery="select * from reader"; } $count=$count+1; } |
| Re: Pls Help With This Php Program by kanirip: 6:35pm On Jan 11, 2011 |
These are one of those post that my normal first reaction is to burst out laughing! Most importantly my friend, you can NOT iterate over a ResultSet ( which is what a select query return when executed on a table in the DB) by calling the SQL Statement again. But here is what you want to achieve in PHP (using PDO): http://www.php.net/manual/en/pdo.exec.php Let me know if you need any more help and I can post examples. |
| Re: Pls Help With This Php Program by naijaswag1: 9:28pm On Jan 11, 2011 |
kanirip:When I see certain frequent posts by those who claim to be programmers who are supposed to be professionals I get irritated.This is especially rampant in this forum amongst incompetent Nigeria programmers who know nothing. Why should you be laughing at this guy? Where you born with php in your dull brains? When you visit all those many tutorial sites hosted by experts from India,US and the Europeans,if their disposition are like those of the useless so called Nigerian experts(that will remain client programmers for a long time) who post rubbish to rookies,would you have learned anything.Was it not by reading other peoples(non-Nigerians) books and tutorials that you learned the little you know that cannot even bring to life a robust software? Show me one framework or an open source php or any other programming project that you are a contributor other than putting one or two things together to create a website that is as dead as Nigeria? |
| Re: Pls Help With This Php Program by kanirip: 2:12am On Jan 12, 2011 |
naija_swag:Here comes, DEFENDER OF THE LAUGHED AT!!! Now my normal first reaction to this is to return the verbal in equal venom but I see you have good intentions so I will pardon you That a person 'insinuates' that he may laugh at a question being thrown out in the wild does not in any way detract from the fact that the person will still provide support for said question. You should try and not be so uptight! You really don't know me but if you want to continue to insult 'useless so called Nigerian experts' , we have a thread for that on Nairaland > Programming section. Please go to https://www.nairaland.com/nigeria/topic-146070.0.html and feel free to insult away. And I really don't program in PHP but I know enough to even help the guy. In your berserkers rage, you forgot to provide any help for the guy! Glad to be of service! |
| Re: Pls Help With This Php Program by naijaswag1: 2:25pm On Jan 12, 2011 |
You really don't know me but if you want to continue to insult 'useless so called Nigerian experts' , we have a thread for that on Nairaland > Programming section. Please go to https://www.nairaland.com/nigeria/topic-146070.0.html and feel free to insult away.Every programming language book,teacher or tutorial always starts with the traditional helloworld program.Every rookie especially those who taught themselves always get bewildered at that mundane program that one latter realizes is the the nursery rhyme of programming languages. The tutors,teachers,tutorial writers and even the inventors of the language keep this tradition no matter the simplicity inherent.The point I am trying to make is that these professionals abroad understand that computer science and computer programming is not a natuaral science or way of thinking.It was invented by man thereby not making it a natural way of thinking.There is a lot of abstraction and logic in it and as such one should expect a novice to throw any kind of question at it while learning. Imagine that you asked a question in a formal class and the teacher burst out laughing and after answered your question.Not everyone loves to be scorned at and in this scenario,it is not helpful to make a jest of someone before giving some directions to questions posed no matter how silly. Let me believe that I don't really know you but I have gotten the message across and I will continue to mete out commensurate venom on many so-called Nigerian programmers who cannot live up to anything in the programming world and not even in Africa where the boys in Nairobi,Johannesburg and Accra are taking the lead. |
| Re: Pls Help With This Php Program by shokergb(op): 3:53pm On Jan 12, 2011 |
it's not still working,let me explain myself a bit more,i'm searching through a database with a select query and i want to control the maximum number of searches,say 3 times.so i gues i need a loop that will terminate the search at say count 3.useful solutions would be highly appreciated. |
| Re: Pls Help With This Php Program by kanirip: 5:47pm On Jan 12, 2011 |
shokergb:I don't understand, Do you want to restrict the amount of rows returned to 3? or, do you want to actually search the table 3 times? If it is the 1st then, you ONLY select once and then get the result and then only get the first 3 rows of the Result set If it is the second, then well, I guess you are on the right path but what would you be trying to achieve doing this? |
| Re: Pls Help With This Php Program by Nobody: 10:05am On Jan 13, 2011 |
@naija_swag. So what is your achievement that makes you any better. You are just blabbing unnecessarily. And if you try that with me, you will get reply from the winds! I get the point of kanrip. It is even a good pattern of teaching. It helps the student know that such pattern is not applicable and also a never to be thought of line. In my opinion the poster needs to paginate his queries. I hope two of you even know what pagination is This one wey una dey fight boxing this new year ![]() **wears his glove in readiness of a blow from naija_swag** @OP. I guess what you need is to query a certain number of data, and on click of a button next or so, the rest turns up? If you just want to output like three fields, you make use of the LIMIT clause in MYSQL Query Like if you want to output the first three fields/datas. You use SELECT * FROM this_field LIMIT 1,3; |
| Re: Pls Help With This Php Program by Nobody: 10:03pm On Jan 13, 2011 |
It's ideal to use While when u want a continous loop with no regard for numbers of iterations but since u want to limit it to three times just use for statement also ur codes looks funny whats the essence of the code at the bottom count + 1 that cud throw it in an infinte loop. |
| Re: Pls Help With This Php Program by Nobody: 10:05pm On Jan 13, 2011 |
someone made a reference to PDO that's a good pratice to abide by,cuz writing MYSQL codes are stressful use PDO Classes if u tried Zend Framework u will never have stress with any work ever. |
Pls Help Me With This Php Code • Help With This Php Code. • I Need Help With This Php Code For Email And Sms Autoresponse • 2 • 3 • 4
Developing Social Networking Website Using PHP And MYSQL • [TUT] How To Make/use Single Name On Facebook • Please, Help On This Resume Builder Project
This one wey una dey fight boxing this new year 