Re: Problem with a script



On Apr 10, 5:15 pm, Schraalhans Keukenmeester <bitbuc...@xxxxxxxxxxxx>
wrote:
Jerim79 wrote:
Here it is:

<?php

if($_SERVER['REQUEST_METHOD']=='POST'){

[snip]

If you know of a way to make the current code work, or if you have a
better idea of how to do this from top to bottom, please let me know.
I would like to also be able to carry over the user's selections, so
that they don't have to recheck each box, if they only left off one.

I don't mean to offend you or discourage you from working with PHP, but:
The way you coded the posted script gives me the impression you haven't
yet grasped and practiced with the basic building blocks of PHP or maybe
even programming in general. (See Rami's comments)

Reworking your huge script into something concise, correct and 'a common
sense coding practise' would probably result in a script hardly
comparable to yours, rendering it mostly useless as a learning
possibility. Commenting/correcting on a line by line basis would require
a post a mile longer than your is already.

If all you really want is a fix for a specific detail, give us only that
and leave out the rest.

Personally I think you may be helped more by leaving this spaghetti for
later, and start getting to grips with PHP's building blocks first. Get
a good (e-)book or tutorial site and begin with short examples and
experiments that help you understand the concepts and PHP's way of doing
things. I know they say PHP has a short learning curve, and compared to
some/many other languages it probably does, but trying to sail even the
simplest boat before you know bow from stern is not advisable.

If I am completely off the mark here, I'm sorry. I just can't find
anything in this post that proves me wrong.

Which books/sites are good/great/rubbish is mainly a subjective choice.
O'Reilly has a few that match MY taste, some are fond of the YOU-NAME-IT
for Dummies approach, others prefer a really dry & theoretical but very
exhausting summary. The pick is yours!

GL.

Sh.

This may come as a total shock to you, and if it does I apologize, but
I don't really care what either of you think concerning my skills. I
am proud of what I have, and it works. It may not be the way you
personally would have done it, but then again, I am not you. To say
that I have no understanding of loops is completely asinine. I use
loops throughout the script. I don't use loops in every particular
instance, because:
1) The script is fresh and I want to maintain some sense of
maintainability for the moment. Condensing things into loops is great
once everything is working and you are sure that the loop will work/
stay. When you are working on something, it is usually best to leave
it in a "spread out" nature so that you can easily identify a problem
as well as keep the design straight. Loops, especially in the early
stages of a script, often become shrouds that cover up where the
problem is occurring.
2) This is not the final version of the script. Tightening up of
a script occurs after you have it working. If you can build a script
from scratch and code it perfectly the first time, every time, then
good for you. Every one else in the universe though usually has to go
through several iterations of a script before they are done. (True,
given enough time, we should all theoretically spend much more time in
design than production. But who has that kind of time?)
3) I don't pretend that I will stay in the same position forever.
Nor do I want some form that only mid level programmers will
understand. When I create something, I want to make sure that someone
else will be able to understand it. Sure, we could all code something
as condensed/complicated as we can, but what of the poor programmer
who comes behind us, who may not be as skilled? I try to straddle the
line between efficient code and maintainable code by a reasonably
knowledgeable programmer for my position. If I am working at small
business with a history of hiring low knowledge employees, I dumb it
down. If I am working at a Fortune 500 company with a history of
hiring only the brightest, then I wouldn't see a problem going as far
you want. I am not saying this applies in this case, but I wanted to
throw that in while I am on the subject of programming.

I have no fundamental knowledge of programming, eh? Really? I can
program in Java, C++, and VB.net. Although I will never present myself
as an expert programmer, maybe not even an experienced one, I most
certainly have a solid grasp of programming. Just because a person
doesn't do something the way you would do it at any particular stage
in the process, doesn't mean they don't have a clue. That is a very
arrogant attitude. I guess like Rami, you are basing that off of me
not using a loop in every particular place that you feel I should. I
wonder if you two would go to the start of the assembly line at the
auto factory, and complain that the car doesn't even have windows
yet.

As for the loop that was given, it may surprise you that I don't label
my variables as $VariableX. Variables should have unique names that
signify what they are. Seeing as how I have unique names for my
variables, a loop there becomes impractical. Unless of course I
utilize pointers, which is open to a matter of discussion of whether
it is worth it or not.

The number one goal should always be to make it work. Trying to
impress everyone with your made programming skills should always take
a back seat to that. But thanks for the criticism that completely
didn't address my question in any form. That was greatly appreciated.
BTW, I was able to solve my own problem. I might even go back and take
out all the loops, remove local variables, take out the method check,
and the data verification. You know, since I don't know what I am
doing and all. :)

.



Relevant Pages

  • Re: Problem with a script
    ... that I have no understanding of loops is completely asinine. ... loops throughout the script. ... business with a history of hiring low knowledge employees, ... throw that in while I am on the subject of programming. ...
    (comp.lang.php)
  • Re: Help: a script to display most popular pages within my website
    ... >> Does anyone know of a script or simple programming allowing me to ... >> scouted the net searching for a script to do this with no success. ... My site is PHP ... JavaScript to display the same headers and footers across the entire site -- ...
    (alt.php)
  • Re: Steve-parkers Bourne sh programming tutorial
    ... > programming along with perl would be very good knowledge to have up-stairs ... > Anyways in the Loops section of that tutorial, ... > same code into a script called while.sh. ... > lol. ...
    (comp.unix.shell)
  • Re: Why php and not C?
    ... Leaping from php to C is one thing, leaping from C to assy is another. ... It might be a point of view or where you started programming from. ... writing a php script is simple and faster. ...
    (comp.lang.php)
  • Re: PHP & AJAX
    ... I would like to write my PHP in an Object Oriented approach. ... What is the limitation on what I can return in AJAX? ... application, I should call a PHP script using AJAX, and in that PHP ... Typically in web programming, you do not keep persistent objects ...
    (comp.lang.php)