•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,589 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,591 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 613 | Replies: 8
![]() |
hi guys...
i have two static value and between 8 and 16 other dynamic variables...which returns from sql queries everything.. like page titles, subjects etc...
everything based on number in tables,
Statics: Language and Index
Dynamic values: Categories from 1 to 6
SubCategories from 1 to 10
system works like this
if language = 1 n index = 1
{
if category = 1
{
if subcategory = 1
{
// code here
}
else if .......
{
// code here
}
else
{
// code here
}
}
}
if i do this in this way like repeating if circles, it ll take around 2000 rows... which means 50kb my question is how i can simplify this code as much as possible??
Thanks in advance
i have two static value and between 8 and 16 other dynamic variables...which returns from sql queries everything.. like page titles, subjects etc...
everything based on number in tables,
Statics: Language and Index
Dynamic values: Categories from 1 to 6
SubCategories from 1 to 10
system works like this
if language = 1 n index = 1
{
if category = 1
{
if subcategory = 1
{
// code here
}
else if .......
{
// code here
}
else
{
// code here
}
}
}
if i do this in this way like repeating if circles, it ll take around 2000 rows... which means 50kb my question is how i can simplify this code as much as possible??
Thanks in advance
Do a favour, leave me alone
Huh, if you have repetitive code use functions!
>it ll take around 2000 rows... which means 50kb
Where did you pick that random number from honey? (50kb) Nonsense!
148 posts and no sign of [code][/code] tags, oh dear.
>it ll take around 2000 rows... which means 50kb
Where did you pick that random number from honey? (50kb) Nonsense!
148 posts and no sign of [code][/code] tags, oh dear.
Last edited by iamthwee : Nov 2nd, 2007 at 4:00 pm.
... the hat of 'is this a cat in a hat?'
putting the most likely candidate for the if statement close to the top of the statement may save time and processing power as once the if gets what it needs the rest of the statement is ignored. also when sorting through the categories the only code that would be executed would be contained in the if for that category so if your category was 1 then it would go something like this:
if($cat ==1) {
// do ifs for sub categories and such
}elseif($cat ==2) {
//stuff for cat 2
etc...
even if you have 18 main categories after 1 none of that would matter because if the category was 1 the if statment would stop there and the rest would be ignored. even though the size of the file is 50k it would be cut dramatically because not all the code would be processed. If this is the question you're asking
if($cat ==1) {
// do ifs for sub categories and such
}elseif($cat ==2) {
//stuff for cat 2
etc...
even if you have 18 main categories after 1 none of that would matter because if the category was 1 the if statment would stop there and the rest would be ignored. even though the size of the file is 50k it would be cut dramatically because not all the code would be processed. If this is the question you're asking
Always do what you wish you could..
•
•
•
•
and even your code page 5kb or 500kb and $cat == 3 everything on the page will be checked until browser reaches the EOF.
the browser only calls the php script, it doesn't execute it, the server does. The browser has nothing to do with it, only what the php script gives the browser is what is displayed
Always do what you wish you could..
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- C command-line I/O question (C++)
- Problem about Bus Topology (Networking Hardware Configuration)
- Recursion Search Help (URGENT!) (C)
- class toString() functionality in C++ ...? (C++)
- installing xp with linux platform running (Windows NT / 2000 / XP / 2003)
- Uber-N00B question (C++)
- Context-sensitive grammar question :( (Computer Science and Software Design)
- Welcome PC Mod Kingdom peeps! (Geeks' Lounge)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
- Changing Network Configuration (*nix Software)
Other Threads in the PHP Forum
- Previous Thread: MySQL SELECT question
- Next Thread: PHP MSSQL APACHE problem in coonecting to database



Linear Mode