Jump to content

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

Just another quick question.

 

If I want my user to be able to select their own font say Arial, is it possible for that font to be added in?

 

Could it be done in a simular way? Store in the DB then get the information out and put it into the CSS?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/85881-php-help/#findComment-438455
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.