On Tuesday, March 5, 2002, at 07:56  PM, Andre Dubuc wrote:

> And thanks again!
> I like the 'function print_name_form()' -- I gather you could do this 
> for all
> the NOT NULL variables that a form requires. Further, would you just 
> change
> the "print_name" to 'print_whatever-other-variable' that I would want to
> check? Is there another way to consolidate the code at this point? Or 
> would I
> just duplicate the code for each not-null variable?

You can name a function whatever you want -- they're arbitrary, 
user-defined puppies.  HOWEVER, the contents of a function need to do 
what you want -- the function that I showed you creates a very specific 
input, named "name" or something like that.  So for each other input you 
want to create within a function, you'd have to make sure that they 
created unique inputs.

Personally, I put all of my inputs into one function, and the function 
itself does both the error checking and the form-printing.  This is 
probably not the cleanest way to do it, but it works -- in this case, 
the function is more of a subroutine than a proper function.  
(Subroutines and functions are more or less the same thing in PHP, 
there's no syntactic difference.)

> [Btw, I sometimes long for the old Paradox PAL code that seemed so 
> difficult
> at the time I learnt it -- PHP is very similar, but the syntax seems so 
> much
> more compact.]

If you get to a point where you feel comfortable with PHP, you might 
consider investigating the Python language.  It's got a very different 
feel, for instance you don't use bucks to indicate variable names, and 
there are braces around function definitions or if statements.  Rather, 
you use whitespace to keep code chunks organized.  Some people believe 
this is a more organized way to write code.  Python is probably more apt 
for writing standalone programs and scripts, whereas PHP is more apt for 
writing web applications, but that's an opinion of mine and you can 
really use either language for either of those.  www.python.org for more 

> While we're on the topic of fields ('input type=text") is there anyway 
> to
> include a non-printing space in the data entry, say for 'Name", that 
> would
> not be passed to the database? Thus, on the screen it would appear:
>       Name: [non-printing space]Andre   but in the database entry:   
> Name:Andre
> This isn't a pressing question, and probably is a formatting question, 
> but I
> wonder if it's possible?

Yes, a formatting/HTML question.  I learned everything I needed to know 
about HTML from Sams Teach Yourself HTML/XHTML in 24 hours or from the 
web itself.  That book was also super super easy.  I'd say a little bit 
too easy if you're already learning things like PHP, which are a more 
advanced topic.  I am not a very good designer, so I can't really answer 
your question directly, but I find that forms lend themselves well to 
being placed within HTML's tables.

print " <table>
                        <tr><td>Name:</td><td><input type=\"text\" name=\"name\" 
                        <tr><td>Password:</td><td><input type=\"password\" 
name=\"password\" /></td></tr>
                        <tr><td>Favorite Sushi</td><td><select name=\"sushi\">
<option value="not bad">Ebi</option>
<option value="daring">Tako</option>
<option value="wimp">California</option>

But when you see this in a web page, it is nicely formatted.  Don't 
forget to customize the way the table looks by declaring borders and 
cell spacing in a style sheet.

Also, as an exercise, come up with a clever way to put this code into a 



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to