Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks.
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
HTML is very easy, and it doesn't make sense to learn PHP without some knowledge of it. But it really shouldn't take you long at all to get your bearings, its just a language for structuring content so it doesn't have the complexity of an actual programming language (CSS, however, has some weirdness that programmers often have trouble understanding, but you won't really need to delve into that at the very beginning).
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
HTML can be learned in a few minutes if you have a good resource. It's very simple. PHP is an actual programming language and is a lot more complex, and you'll need to know html before you can actually use it much. You can learn the two fairly well in a summer in my opinion.
hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
I never really understood what is "learning HTML". Like, it's a markup language, some way to structure data, in order to be visually represented, and only that. There isn't much to do with it or be understood, unless you delve into some advanced stuff. What you should learn is the full combo "HTML + Javascript + CSS" or "HTML + PHP". You mainly have to learn a language that can use or produce HTML, otherwise it's pretty pointless.
On April 24 2013 17:33 FFGenerations wrote: hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
(the foreach doesnt work fyi. i have to fuck off now for 2 hours but will be back to have another look)
Firstly, quit using the mysql library, its awful and deprecated. Use mysqli or PDO instead.
Secondly, you can't use foreach here because you don't actually have an array, all you have is a single function return value (which is a single row, although it is an array of *columns*). mysql_fetch_array returns 1 row at a time, and with the while loop version you're calling it over and over again as long as it returns a non-falsy value (so you iterate over all the rows).
Foreach however, instead of evaluating a condition each time, will loop through an array or an iterator. Since all you have here is one row, that clearly won't do what you want. You could, however, construct an Iterator class that makes calls to mysql_fetch_array() to iterate, and then you could get this syntax. Before you run off and do that though, just stop using the mysql functions and move to mysqli, where the result type already implements Iterator and can do this.
On April 24 2013 17:33 FFGenerations wrote: hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
(the foreach doesnt work fyi. i have to fuck off now for 2 hours but will be back to have another look)
Generally you can make them do the same thing in the end (not 100% sure with php) however:
One of them is a general purpose loop with pre-condition and another is a dedicated loop operator to loop over ARRAYS.
In general i prefer to use Foreach, purely because i think it produces less bugs and issues, and for me is easier to read when looking through a mass of code.
So it loops through the array an execute the code for each element.
While however loops as long as the statement in between the "( )" is true, and than executes the code everytime.
The reason why you cannot use foreach in that case is, that if you have mutiple rows in your Mysql Table the mysql_fetch_* functions will only give you one row, and than put the pointer to the next row. If mysql_fetch_array, gets called it will give you the first and than move on to the second. If you call it again it will give you the second row and move the pointer to the third. To get every row you need to repeat that for every row in your table, and if there are no more rows avaiable mysql_fetch_array will return "false".
The easiest way to do this is witj a while function, like in your example, after every iteration $row, will have a new content and the loop will run until you run out of rows(mysql_fetch_array returns false).
This only works with while(well you could make it work with foreach, but that would be retarded).
On April 24 2013 17:58 Rixxe wrote:
Generally you can make them do the same thing in the end (not 100% sure with php) however:
One of them is a general purpose loop with pre-condition and another is a dedicated loop operator to loop over ARRAYS.
In general i prefer to use Foreach, purely because i think it produces less bugs and issues, and for me is easier to read when looking through a mass of code.
You cannot say that one is better than the other, as they have quite different purposes.
wow thanks, thats just what i wanted to hear. theres so much you dont learn in a class, they give you the code and say "this is how you do it", then you get an assignment in which you copy/paste what you've done in class.
thankfully this is my last assignment for a while (excluding the CCNA, which you can also copy/paste directly off the internet to get a good grade in), as soon as i get it out the way im going to start a proper C++ book/tutorial.
never heard of mysqli - and how would i!? one thing at a time, let me get this submitted with a top grade based on the requirements (which are "paste what you done in class and screenshot it 100 times") then i can start from scratch in detail
On April 24 2013 19:15 FFGenerations wrote: wow thanks, thats just what i wanted to hear. theres so much you dont learn in a class, they give you the code and say "this is how you do it", then you get an assignment in which you copy/paste what you've done in class.
thankfully this is my last assignment for a while (excluding the CCNA, which you can also copy/paste directly off the internet to get a good grade in), as soon as i get it out the way im going to start a proper C++ book/tutorial.
never heard of mysqli - and how would i!? one thing at a time, let me get this submitted with a top grade based on the requirements (which are "paste what you done in class and screenshot it 100 times") then i can start from scratch in detail
On April 24 2013 19:15 FFGenerations wrote: wow thanks, thats just what i wanted to hear. theres so much you dont learn in a class, they give you the code and say "this is how you do it", then you get an assignment in which you copy/paste what you've done in class.
thankfully this is my last assignment for a while (excluding the CCNA, which you can also copy/paste directly off the internet to get a good grade in), as soon as i get it out the way im going to start a proper C++ book/tutorial.
never heard of mysqli - and how would i!? one thing at a time, let me get this submitted with a top grade based on the requirements (which are "paste what you done in class and screenshot it 100 times") then i can start from scratch in detail
You should hit me up for the C++ stuff
i second this. you should even read his blogs. very easy to understand
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
On April 24 2013 09:12 HadeCiao wrote: I wanted to share my programming experience with you. I have always been fascinated about computers and algorithms. 1 year ago I downloaded logism, a logic circuit simulator. I wanted to understand computers from scratch. I finnaly was able to build a very small cpu and also a simple assembly language in which I could write pong.
Just recently I could afford more time to spend on learning how computers work. I have been reading now and then (also in this thread) about programming, As far as I knew Java, C and Basic are the most basic and common languages and Basic seemed to be ideal for a beginner like me. After watching a few tutorials, I started with pong then snake and tretris. Finnaly I ended up programming a metroid clone within the last 4 weeks.
The programming process itsself was great, i spend nights and nights solving those little problems and improving the game on a constant basis. After showing the game to a few friends I was suggested to give it a try and uploaded it to steam greenlight. The reactions are quite negative mainly due to the cheap graphics. However I am an aweful painter and now I am stuck a little. Need to calm down a few days :D However I do not regret anything and I want to give a shout how great and fun programming is.
Here is the promotion vid for those who are interested.
On April 24 2013 19:15 FFGenerations wrote: never heard of mysqli - and how would i!? one thing at a time, let me get this submitted with a top grade based on the requirements (which are "paste what you done in class and screenshot it 100 times") then i can start from scratch in detail
Well, its quite simple to hear of it. Any time you go to the documentation for the mysql crap on the php site, they have a nice big warning bar telling you not to use it and to use mysqli instead, e.g.: http://www.php.net/manual/en/function.mysql-result.php
If your class is focused on copying and pasting, you should immediately stop going to that class and do something useful with your time instead.
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
Any reason why you want to learn php?
I'm not here to criticize--I'm fairly new to web development myself (getting the hang of play framework atm)--but I'm just wondering what made you choose php over other popular frameworks, such as rails and django.
I for one chose play because I was learning scala on the side. Thought it would be a good idea to do something with what I've learned. I also have a project in mind.
Note: I know it's wrong to consider php a web framework, but you know what I mean . I'm just not familiar with any popular php frameworks.
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
Any reason why you want to learn php?
I'm not here to criticize--I'm fairly new to web development myself (getting the hang of play framework atm)--but I'm just wondering what made you choose php over other popular frameworks, such as rails and django.
I for one chose play because I was learning scala on the side. Thought it would be a good idea to do something with what I've learned. I also have a project in mind.
Note: I know it's wrong to consider php a web framework, but you know what I mean . I'm just not familiar with any popular php frameworks.
There is one reason why PHP is a common choice to learn: It's what everyone uses, so it provides the best job opportunities.
Yes, it's a horrible language and i don't like it but if you look at it from a real-world perspective, making code look pretty doesn't matter, results matter. That is what PHP has: Results.
On April 24 2013 17:33 FFGenerations wrote: hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
(the foreach doesnt work fyi. i have to fuck off now for 2 hours but will be back to have another look)
Firstly, quit using the mysql library, its awful and deprecated. Use mysqli or PDO instead.
***snip***
I wholeheartedly agree. PDO is so much better than the standard mysql_* functions and only a tiny bit more complex. Coming originally from Perl with it's DBI library, it feels a lot more natural to me as well. Anyone who still uses mysql_* deserves a strong kick in the lower body region.
On April 25 2013 19:29 Morfildur wrote: There is one reason why PHP is a common choice to learn: It's what everyone uses, so it provides the best job opportunities.
Yes, it's a horrible language and i don't like it but if you look at it from a real-world perspective, making code look pretty doesn't matter, results matter. That is what PHP has: Results.
PHP, Python, Ruby, Scala, the choice of language doesn't matter in the end, only results do. Bad coders write bad code in every language.
It certainly provides the most job opportunities, but the best ones? I read an article several years back showing that Ruby web developers on average made quite a bit more money than PHP developers.
Obviously, PHP is still worth learning if you want a lot of opportunities, but I think the trend is to move away from PHP and there's far more opportunities now in other languages... and finding a job in pretty much any discipline shouldn't be a huge issue, it's more dependant on what you want to work with... Ruby for innovative upstarts, ASP/JSP are probably also very easy to find work in as part of bigger companies.
On April 25 2013 19:29 Morfildur wrote: There is one reason why PHP is a common choice to learn: It's what everyone uses, so it provides the best job opportunities.
Yes, it's a horrible language and i don't like it but if you look at it from a real-world perspective, making code look pretty doesn't matter, results matter. That is what PHP has: Results.
PHP, Python, Ruby, Scala, the choice of language doesn't matter in the end, only results do. Bad coders write bad code in every language.
It certainly provides the most job opportunities, but the best ones? I read an article several years back showing that Ruby web developers on average made quite a bit more money than PHP developers.
Obviously, PHP is still worth learning if you want a lot of opportunities, but I think the trend is to move away from PHP and there's far more opportunities now in other languages... and finding a job in pretty much any discipline shouldn't be a huge issue, it's more dependant on what you want to work with... Ruby for innovative upstarts, ASP/JSP are probably also very easy to find work in as part of bigger companies.
Average salary is a very wierd statistic since it only shows half the picture.
Ruby developers might earn more on average but that is because most of them are experienced programmers working in a company that is financially secure enough to take a risk with the language, so they have the freedom to pay more.
The huge amount of novice PHP programmers in low paying startups pulls the average salary down a lot. Good PHP programmers will earn as much as good Ruby programmers in the same context.
While there are jobs for all languages, the amount of PHP jobs is still higher than that of any other web language, especially for novice programmers. Experienced programmers will program in any language anyways, so they don't have to care about that.
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
Any reason why you want to learn php?
I'm not here to criticize--I'm fairly new to web development myself (getting the hang of play framework atm)--but I'm just wondering what made you choose php over other popular frameworks, such as rails and django.
I for one chose play because I was learning scala on the side. Thought it would be a good idea to do something with what I've learned. I also have a project in mind.
Note: I know it's wrong to consider php a web framework, but you know what I mean . I'm just not familiar with any popular php frameworks.
There is one reason why PHP is a common choice to learn: It's what everyone uses, so it provides the best job opportunities.
Yes, it's a horrible language and i don't like it but if you look at it from a real-world perspective, making code look pretty doesn't matter, results matter. That is what PHP has: Results.
On April 24 2013 17:33 FFGenerations wrote: hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
(the foreach doesnt work fyi. i have to fuck off now for 2 hours but will be back to have another look)
Firstly, quit using the mysql library, its awful and deprecated. Use mysqli or PDO instead.
***snip***
I wholeheartedly agree. PDO is so much better than the standard mysql_* functions and only a tiny bit more complex. Coming originally from Perl with it's DBI library, it feels a lot more natural to me as well. Anyone who still uses mysql_* deserves a strong kick in the lower body region.
I disagree with such generalized statement as "bad coders write bad code in any language". Quality of code is not binary measure. And languages influence how bad the code can get. Plus all programmers write bad code to some degree, good language helps you avoid some of that. Bad code is unavoidable, if language can prevent some of it, that language is better. Of course there is balance to be had between how much language constricts you without actually preventing you to use useful techniques.
PHP is terrible language and it matters (even though not to some very big degree). But which languages are used is not based on quality or even pure usefulness of the language, but on factors independent of the language itself (libraries, frameworks, community, support, ...). Basically PHP has results, because it is popular, simple feedback loop.
That is not to discourage someone from learning PHP, but if they are not pressed to start with it by necessity of earning money or something, it is not ideal first language, not even for creating web pages.
On April 24 2013 11:51 white_horse wrote: Is it possible to teach yourself HTML and be pretty good at it? I'm planning on studying intensively on my own this summer.
Also, should I learn HTML first or PHP, or should I study both at the same time?
Any reason why you want to learn php?
I'm not here to criticize--I'm fairly new to web development myself (getting the hang of play framework atm)--but I'm just wondering what made you choose php over other popular frameworks, such as rails and django.
I for one chose play because I was learning scala on the side. Thought it would be a good idea to do something with what I've learned. I also have a project in mind.
Note: I know it's wrong to consider php a web framework, but you know what I mean . I'm just not familiar with any popular php frameworks.
There is one reason why PHP is a common choice to learn: It's what everyone uses, so it provides the best job opportunities.
Yes, it's a horrible language and i don't like it but if you look at it from a real-world perspective, making code look pretty doesn't matter, results matter. That is what PHP has: Results.
PHP, Python, Ruby, Scala, the choice of language doesn't matter in the end, only results do. Bad coders write bad code in every language.
On April 24 2013 17:55 tec27 wrote:
On April 24 2013 17:33 FFGenerations wrote: hey, i have to rush off now, but perhaps one of you would fancy answering a question?
i am printing contents of my product table to a webpage (menu of food items)
my tutor used While to do this but i dont really know why, or why you cant use Foreach
i dont need a 100% answer, just a very general answer would be sufficient for me to see how my understanding lacks (i am total beginner). something like "they both work completely different and you need to study up on them properly to know why and how"
(the foreach doesnt work fyi. i have to fuck off now for 2 hours but will be back to have another look)
Firstly, quit using the mysql library, its awful and deprecated. Use mysqli or PDO instead.
***snip***
I wholeheartedly agree. PDO is so much better than the standard mysql_* functions and only a tiny bit more complex. Coming originally from Perl with it's DBI library, it feels a lot more natural to me as well. Anyone who still uses mysql_* deserves a strong kick in the lower body region.
I disagree with such generalized statement as "bad coders write bad code in any language". Quality of code is not binary measure. And languages influence how bad the code can get. Plus all programmers write bad code to some degree, good language helps you avoid some of that. Bad code is unavoidable, if language can prevent some of it, that language is better. Of course there is balance to be had between how much language constricts you without actually preventing you to use useful techniques.
PHP is terrible language and it matters (even though not to some very big degree). But which languages are used is not based on quality or even pure usefulness of the language, but on factors independent of the language itself (libraries, frameworks, community, support, ...). Basically PHP has results, because it is popular, simple feedback loop.
That is not to discourage someone from learning PHP, but if they are not pressed to start with it by necessity of earning money or something, it is not ideal first language, not even for creating web pages.
out of curiosity, what is ideal in creating web pages?