Avatar of MayoorPatel
MayoorPatel

asked on 

Inserting Code into a page with Case Statements

Hi there I have a variable called merchant, and dependiing on that the value of the merchant I would like to embed certain code on my page PHP page.

Here is an example of what I would have to embed. Obviously there are going to be several versions of this code and the one embeded wil depend on the value of the varibale "merchant"

<?php require("/home/onlin/public_html/cstfr/lib_util.php"); ?>
<?php
mk_start(); gco_();
?>
<?php gcc('http://www.anrdoezrs.net/click-3081365-14577101','jamesons-02a74b5c2b89d13b445ee16bb9f1d339',1000); ?>
<?php mk_start_(); ?>

Can anyone help?
Scripting LanguagesPHP

Avatar of undefined
Last Comment
MayoorPatel
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image


switch ($merchant) {
	case "cosco":
		//do this code
		break;
		
	case "walmart":
		//do this code
		break;
	
	case 123:
		//cases can be numeric
		break;
		
	case (trim($merchant) != ""):
		//cases can also be expressions
		break;
		
	default:
		//the default case when none of the other cases were a match
		break;
}

Open in new window

Avatar of MayoorPatel
MayoorPatel

ASKER

Thats great, but how do I output the actual code, do I just paste it into the case like this

switch ($userId) {
        case "1":
               <?php require("/home/onlin/public_html/cstfr/lib_util.php"); ?>
<?php
mk_start(); gco_();
?>
<?php gcc('http://www.anrdoezrs.net/click-3081365-14577101','jamesons-02a74b5c2b89d13b445ee16bb9f1d339',1000); ?>
<?php mk_start_(); ?>
                break;
               
        case "walmart":
                //do this code
                break;
       
        case 123:
                //cases can be numeric
                break;
ASKER CERTIFIED SOLUTION
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of MayoorPatel
MayoorPatel

ASKER

very good
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo