[FX.php List] Which is faster?
Leo R. Lundgren
leo at finalresort.org
Sat Sep 11 13:48:11 MDT 2010
11 sep 2010 kl. 21.33 skrev Bob Patin:
> On Sep 11, 2010, at 2:27 PM, Leo R. Lundgren wrote:
>
>> 11 sep 2010 kl. 21.21 skrev Bob Patin:
>>
>>> Very cool. I was going to use this:
>>>
>>> <input type="checkbox" name="service<?php echo $counter; ?>">
>>
>> If you do it this way, how are you going to know which posts to query the database for? All you have is a series of numbers not relating to the posts at all (assuming $counter is something that starts at 0 or something and is incremented for each record in page one).
>
> That was how I was going to do it when I was going to capture the entire record for each item, so I'd end up with a set of data for each item:
>
> description0 = My item
> type0 = treadmill
> serial0 = 12345
> recid0 = 5001
>
> and so on...
>
> But i could potentially end up with a HUGE bunch of data. I like your method much better.
Oh, yeah. Don't do that. Instead group the form data in arrays for easy retrieval on the recieving side.
Would be funny the day that you build a page that dynamically adds records to the form, so that when you recieve the form you don't know how many items there are to loop through. I guess you'd have to either do a big loop to cover the possible/likely number of items (fetching them via nameX), or some other thing which is more clunky.
> Is it better, in a multi-predicate IF statement, to use && instead of "and"?
>
> I've always written
>
> if (($x = 1) and ($y=3)){
>
> Is && a better way?
They are not the same thing, so which one you want to use depends on what you need. If I were you, I would happily use && instead of 'and'. It's what I default to and in most cases probably what you want/are thinking of.
See http://se.php.net/manual/en/language.operators.precedence.php for a list of their precedence, and http://se.php.net/manual/en/language.operators.logical.php for some discussion about their differences.
-|
More information about the FX.php_List
mailing list