Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:06:47+00:00 2026-06-12T12:06:47+00:00

Hey all i have the following code to change out an image and the

  • 0

Hey all i have the following code to change out an image and the background color every time an image changes:

$buildGrx = '';

if ($cssColor1 <> '') {$buildGrx = '\'uploadImage/bannerImg/slider/1.jpg\','; }
if ($cssColor2 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/2.jpg\','; }
if ($cssColor3 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/3.jpg\','; }
if ($cssColor4 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/4.jpg\','; }
if ($cssColor5 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/5.jpg\','; }
if ($cssColor6 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/6.jpg\','; }
if ($cssColor7 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/7.jpg\','; }
if ($cssColor8 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/8.jpg\','; }
if ($cssColor9 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/9.jpg\','; }
if ($cssColor10 <> '') {$buildGrx .= '\'uploadImage/bannerImg/slider/10.jpg\','; }

$buildGrx = substr($buildGrx, 0, strlen($buildGrx) - 1); 

var imgArr = new Array( // relative paths of images
 <?PHP echo $buildGrx ?>
 );

 var preloadArr = new Array();
 var i;
 var colorsCSS = new Array();

 colorsCSS[0] = '#fff';
 colorsCSS[1] = '<?PHP echo $cssColor1 ?>';
 colorsCSS[2] = '<?PHP echo $cssColor2 ?>';
 colorsCSS[3] = '<?PHP echo $cssColor3 ?>';
 colorsCSS[4] = '<?PHP echo $cssColor4 ?>';
 colorsCSS[5] = '<?PHP echo $cssColor5 ?>';
 colorsCSS[6] = '<?PHP echo $cssColor6 ?>';
 colorsCSS[7] = '<?PHP echo $cssColor7 ?>';
 colorsCSS[8] = '<?PHP echo $cssColor8 ?>';
 colorsCSS[9] = '<?PHP echo $cssColor9 ?>';
 colorsCSS[10] = '<?PHP echo $cssColor10 ?>';

 /* preload images */
 for(i=0; i < imgArr.length; i++){
    preloadArr[i] = new Image();
    preloadArr[i].src = imgArr[i];
 }

 var currImg = 1;
 var intID = setInterval(changeImg, 6000);

 /* image rotator */
 function changeImg(){
     alert(currImg);
    $('#pageBG').animate({opacity: 0}, 1000, function(){
    $(this).css('background-image','url(' + preloadArr[currImg++%preloadArr.length].src +')');
    $(this).css('background-color', colorsCSS[currImg]);
 }).animate({opacity: 1}, 1000);
 }

and the HTML code that it changes:

 echo '<div align="center" style="background-image:url("#"); background-color:"#fff"; background-repeat:no-repeat; background-position:center top; height:287px;" id="pageBG"></div>';

However, the problem is that it, for some reason, screws up the html code:

 <div align="center" id="pageBG" height:287px;"="" top;="" background-position:center="" background-repeat:no-repeat;="" background-color:"#fff";="" #");="" style="opacity: 1; background-image: url(&quot;http://www.thehamiltonfirm.com/hf-blog/uploadImage/bannerImg/slider/2.jpg&quot;);"></div>

So what could i be doing in order for it to jumble like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:06:48+00:00Added an answer on June 12, 2026 at 12:06 pm

    You can omit quotes in background-image:url("#"); –> background-image:url(#);

    background-color:"#fff"; –> background-color: #fff; – quotes are unnecessary here.

    All style properties in tag wrapped by quotes style="", inside style attribute is not allowed use the same quotes, instead "" necessary use '' (style="background-image: url('#');"). So, echo use single qoutes too, quotes inside style must be escaped: style="background-image: url(\'#\');".

    <?php
        echo '<div align="center" 
                   style="background-image: url(\'#\'); 
                   background-color: #fff; 
                   background-repeat: no-repeat; 
                   background-position: center top; 
                   height: 287px;" id="pageBG">
              </div>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I have the following code: http://jsfiddle.net/g7Cgg/ As you can see, there are
hey all, Im stumped. I have the following code..works fine in all browsers except
Hey all i have the following js code to validate a textbox: function submitContactUs()
Hey all. I have a question on how to implement the following with Django.
Hey all, basically i have an empty AS3 fla file with just the following
Hey all, this is the code i have to check for a day thats
Hey all. Here is the scenario. I have the below code, and I'm needing
Hey all, I'm about to rip my hair out. I have this client that
Hey I have the following code which I'm using to isolate the a b
Hey all, I have the following problem. I recently added an extra column to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.