The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How do I do this in php
This is a very basic question and since I know 0 about php, I dont know how to do it
I have 30 different "if" conditions and I dont know how to do them properly. Its for a shopping website. I want to say If the category is Shoes, then print "Shoes" on the screen. If The category is Belts, print Belts. I need it to run fast because my site is busy and I dont want it to slow my site down. This is what I have now, but for 30 different categories: < ?php if (is_category('Shoes')) { echo "Shoes"; } ?> < ?php if (is_category('Belts')) { echo "Belts"; } ?> < ?php if (is_category('Ties')) { echo "Ties"; } ?> < ?php if (is_category('tshirts')) { echo "tshirts"; } ?> < ?php if (is_category('Socks')) { echo "Socks"; } ?> and so on and so on. See the problem? I start and stop 30 different programs right at the top of the page. Anyone know how I can make that all into 1 big program, instead of a lot of little programs? so it runs faster? thanks for any help! |
#2
|
|||
|
|||
switch case should help you
http://de.php.net/manual/en/control-...res.switch.php |
#3
|
|||
|
|||
Quote:
Sorry Im really a dummy at programming. If there an easy way to do nested if/else in 1 program block without stopping it and starting over? |
#4
|
||||
|
||||
<?php
if(is_category('Shoes')) { echo 'Shoes'; } elseif(is_category('Socks')) { echo 'Socks'; } else { echo 'No category'; } ?> perhaps you mean something like this? |
#5
|
|||
|
|||
Quote:
Would that run faster than my first example of starting and stopping the programs? Or would they run at the same speed? |
#6
|
|||
|
|||
You need some kind of input...like what you are going to check is the category of.
Example: PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|