More study about PHP "break" shows that only operates in for/while/switch type structures, not if() structures, but it is not unequivocally clear whether a break inside an if will operate on the for outside it.
But yet, it moves...
More study about PHP "break" shows that only operates in for/while/switch type structures, not if() structures, but it is not unequivocally clear whether a break inside an if will operate on the for outside it.
But yet, it moves...
How would you place a 'break' inside an 'if' anyway?
if ($a == 1) {
dosomething;
break ;
} else {
dosomethingelse;
break ;
}
Clearly, there is nothing to break out of here.
if ($a == 1) {
dosomething;
break ;
dosometyhingelse ;
}
That may work, sort of, but even if it did, it is clearly a pointless thing to do, the 'dosometyhingelse' will never be invoked.
What other possible scenarios are there?
-------------------------------------
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if (isset($column_list[$i]) && $column_list[$i] == 'PRODUCT_LIST_NAME') {
$_GET['sort'] = $i+1 . 'a';
$listing_sql .= " order by p.products_sort_order, pd.products_name";
break;
} else {
$listing_sql .= " order by p.products_sort_order, pd.products_name";
break;
}
}
-------------------------------------
Just for grins, I've stepped through this code and torvista is correct, this code only checks the first column defined, not all of them.
Cheers
Rod
That code only runs if the setting is:
1 Blank
2 Invalid choice
to set up a valid order by for:
The IF allows for an invalid setting to be used on the ELSE portion that may be wanted that goes beyond the normal settings such as if you wanted a method for products_date_added and set to 5a (an invalid choice if only 4 columns are defined) by using:Code:$listing_sql .= " order by p.products_sort_order, pd.products_name";
While not eloquent ... it makes the change easier to change on the default display order for the listing ...Code:} else { echo 'ELSE ' . '<br>'; // sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER is left blank // for reverse, descending order use: // $listing_sql .= " order by p.products_sort_order desc, pd.products_name"; // $listing_sql .= " order by p.products_sort_order, pd.products_name"; $listing_sql .= " order by p.products_date_added, pd.products_name"; break; }
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
To summarize ...
Correct. At the present time the code only deals with two characters.
But, harmless.
Actually, it should probably be expanded to allow for 0-thru-9.
Ya, probably a bug.
Yet, it appears Ajeh has posted about a curious beneficial side-effect which can utilize this for positive results.
Indeed, in the case of "20a", the "0a" has no effect, and is essentially ignored, since it is neither "a" nor "d", and thus the current code uses other defaults.
Changing it to "2a" doesn't necessarily accomplish the desired end result either, depending what your desired end result is.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
ok, thanks for the confirmations.
This all came about while trying to understand the default sorting mechanisms...
Steve
github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...
Bookmarks