megetron Posted February 16, 2012 Share Posted February 16, 2012 hi, I need a code that switch the background of a stylesheet according to url parameter. I am using this (it wont work): <div class="wFormContainer" style="width:880px; background-image: url(<?(empty($_GET['iswoman'])) ? 'l_banner1.jpg' : 'l_banner1_man.jpg';?>);background-color:#FFFFFF;background-repeat: no-repeat;margin:auto;"> please help Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/ Share on other sites More sharing options...
trq Posted February 16, 2012 Share Posted February 16, 2012 Define "it wont work". Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318013 Share on other sites More sharing options...
megetron Posted February 17, 2012 Author Share Posted February 17, 2012 Define "it wont work". here is the output: <div class="wFormContainer" style="width:880px; background-image: url(<?(empty($_GET['iswoman'])) ? 'l_banner1.jpg' : 'l_banner1_man.jpg';?>);background-color:#FFFFFF;background-repeat: no-repeat;margin:auto;"> Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318193 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2012 Share Posted February 17, 2012 Replace <? with <?php echo . Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318195 Share on other sites More sharing options...
megetron Posted February 17, 2012 Author Share Posted February 17, 2012 Replace <? with <?php echo . now the output is this: <div class="wFormContainer" style="width:880px; background-image: url(<?php echo (empty($_GET['iswoman'])) ? 'l_banner1.jpg' : 'l_banner1_man.jpg';?>);background-color:#FFFFFF;background-repeat: no-repeat;margin:auto;"> Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318196 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2012 Share Posted February 17, 2012 What is the extension of that file? Is it .php or something else? Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318197 Share on other sites More sharing options...
megetron Posted February 17, 2012 Author Share Posted February 17, 2012 What is the extension of that file? Is it .php or something else? php Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318198 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2012 Share Posted February 17, 2012 You're going to need to post more of the file. At least 10 lines before and 10 lines after the line you posted above. Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318199 Share on other sites More sharing options...
Drummin Posted February 17, 2012 Share Posted February 17, 2012 Does the following show image? <div class="wFormContainer" style="width:880px; background: url('l_banner1_man.jpg'); background-color:#FFFFFF; background-repeat: no-repeat; margin:auto;"> How about this. <div class="wFormContainer" style="width:880px; background: url('<?php echo (empty($_GET['iswoman'])) ? 'l_banner1.jpg' : 'l_banner1_man.jpg';?>'); background-color:#FFFFFF; background-repeat: no-repeat; margin:auto;"> Are images in the same directory as this file? Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318200 Share on other sites More sharing options...
megetron Posted February 17, 2012 Author Share Posted February 17, 2012 You're going to need to post more of the file. At least 10 lines before and 10 lines after the line you posted above. ok here is the issue, I added to my htaccess this lines: <Files "default.php"> ForceType 'text/html; charset=UTF-8' </Files> after I remove this, your suggestion is working. but now everything is encoded bad.,.. Here is the page: http://cf.affilinn.co.il/selanet/education please advise. Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318201 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2012 Share Posted February 17, 2012 Then this is an Apache issue, not a php issue? Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318203 Share on other sites More sharing options...
megetron Posted February 17, 2012 Author Share Posted February 17, 2012 Then this is an Apache issue, not a php issue? I struggle this for 24 hours this is frustrating.,.. The Hosting server says that I needs to change the code some how to add encoding support. I add the META tag for UTF-8, and saved the file as utf-8 and even used the header() tag to change php utf-8.... the only way to make encoding work is to change the utf-8... Quote Link to comment https://forums.phpfreaks.com/topic/257107-how-to-select-background-by-query-string-parameter/#findComment-1318210 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.