Jump to content

PHP Help


Ell20

Recommended Posts

Hi,

 

I have a website which uses one CSS for all sites my users create.

 

However would it be possible to add a feature in the Admin panel for the user to select the basic colour e.g Red, Blue, Green

 

Once submitted the colour of the page can be changed using this?

 

I have a database so I could store say Red into the club table. Then use a query to check what colour is stored then say if($css == Red) { use this css } kind of thing?

 

I hope this kind of makes sense.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/
Share on other sites

Of course. Make sure you have different stylesheets for PHP to pick. After all, you can't put variables into stylesheets. ;)

 

Actually you can put variables in stylesheets using php. Just need to set the header as text when you deliver the css / php file to the l client. As long as the stylesheet is on your server you can put as much php as you want in it.

 

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/#findComment-438464
Share on other sites

Of course. Make sure you have different stylesheets for PHP to pick. After all, you can't put variables into stylesheets. ;)

 

Actually you can put variables in stylesheets using php. Just need to set the header as text when you deliver the css / php file to the l client. As long as the stylesheet is on your server you can put as much php as you want in it.

 

 

How do you mean? Sorry I dont follow?

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/#findComment-438466
Share on other sites

<?php header("Content-type: text/css"); ?>
/* Rest of your CSS stuff goes here*/
body {
background-color: <?php echo $bgcolor; ?>
}

 

Save it as something.php and you can call it from another file. That way, you can put variables into external stylesheets.

 

<html>
<head>
<link href="something.php" rel="stylesheet" type="text/css" />
</head>
</html>

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/#findComment-438468
Share on other sites

I have just tried this.

 

I have got it working if I just set the variables within the page e.g:

 

<?php
header("Content-type: text/css");
$pageBG = '#fff';
?>

body {
background:<?=$pageBG?>;
}

 

However ideally I would like to be able to use a mysql query to query the database and get the colours entered by the user.

 

Is this possible?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/#findComment-440214
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.