The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> CSS Help
|
a Question about php, css and mysql
Discuss a Question about php, css and mysql in the CSS Help forum on Dev Shed. a Question about php, css and mysql Cascading Style Sheets (CSS) forum discussing all levels of CSS, including CSS1, CSS2 and CSS Positioning. CSS provides a robust way of applying standardized design concepts to your web pages.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 15th, 2001, 09:45 PM
|
|
Junior Member
|
|
Join Date: Apr 2001
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Hi everybody,
I'm new in this forum.. 
I got a problem can u guys help me??
I'm trying to make a control panel for my guestbook. Therefore I wanna modify the font and css, I insert the font face and css into the datebase...
and the font face and css were linked, which was like this ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"
but when I called it out, the css didn't work, so I read the source code from ie.....I can only see ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"....can somebody tell how to do it??
|

April 15th, 2001, 10:42 PM
|
 |
<insert title here>
|
|
Join Date: Mar 2001
Location: at home
Posts: 405
Time spent in forums: 2 h 29 m 59 sec
Reputation Power: 13
|
|
|
I am guessing you are trying to add an inline style declaration inside your html. I could see how that would make changes easier but I really suggest using external style sheets over db. There might be a reason for your idea, so i will leave it alone. I also have two suggestions.
My first which is my personal preference is to create one external sheet that is applied to all pages. All you have to do is add a link tag in the head of your html like so:
<link rel="stylesheet" href="styles.css">
then you have one style sheet that is applied to all pages. Then theres the other way.
And there is nothing wrong with your css. It's your PHP, database. If you don't see your variables inside the source window the code didn't execute correctly. Try posting the actual PHP if you can't figure it out. Sometimes it is easier for someone who is not frustrated about it to find the problem. If your code is working than you will see:
.text {text-decoration: none; color: #660; font-family: #360; font-size: 9pt}
instead of
text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"
in your source window. And if you didn't add the quotes here for the post they need to be escaped inside <? ?>tags like so \" or the PHP engine try to parse what's inside.
__________________
--the key to life is avoiding death--
|

April 15th, 2001, 10:50 PM
|
|
Junior Member
|
|
Join Date: Apr 2001
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Hi,
thx for replying...^^
let me write more detail...
I wrote this in the php code...
$getdata = "SELECT * FROM modify";
$getdata_result = mysql_query($getdata) or die("WRONG");
$row = mysql_fetch_array($getdata_result);
$font = $row["font"];
$fontcolor = $row["fontcolor"];
$css = $row["css"];
the above data were selected from the data base...
and then in the index.php
I wrote....
<style type="text/css">
<?echo $css ?>
</style>
But when I checked the source code from IE.....
I only saw
<style type="text/css">
.text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}
</style>
it seems like the php code hasn't been processed..>.<
Last edited by Smoking Joe : April 15th, 2001 at 10:54 PM.
|

April 15th, 2001, 11:14 PM
|
 |
<insert title here>
|
|
Join Date: Mar 2001
Location: at home
Posts: 405
Time spent in forums: 2 h 29 m 59 sec
Reputation Power: 13
|
|
|
I just tried this out:
<html><?php
$font = "tahoma";
$fontcolor = "red";
$css = ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}";
?>
<style type="text/css">
<?echo $css ?>
</style>
</html>
---------------and it resulted in:
<html>
<style type="text/css">
.text {text-decoration: none; color: red; font-family: tahoma; font-size: 9pt}
</style>
</html>
I am just guessing but I would say from the looks of all this your script is working fine. I might be overlooking something but I think the problem is in your db. Manually check to make sure the values didn't get input as font and fontcolor instead of hex numbers. I think your input script might be the culprit not this one. Let me know if i am wrong.
|

April 16th, 2001, 08:05 AM
|
|
Apprentice Deity
|
|
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237

Time spent in forums: 4 m 8 sec
Reputation Power: 17
|
|
|
If the css field in your db references the PHP variables $font and $fontcolor (which from what you are trying to do it appears it does) you'll need to tell PHP to look for them as it won't replace them automatically. Instead of:
$css = $row["css"];
use:
$css= eval($row[css]);
|

April 16th, 2001, 02:03 PM
|
|
Junior Member
|
|
Join Date: Apr 2001
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
thank you..!!  
I tried "$css= eval($row[css]);"
but it showed "
Parse error: parse error in ../data.php(26) : eval()'d code on line 1"
can u tell wut the problem is??
sorry....I'm not really good at PHP..
|

April 16th, 2001, 03:00 PM
|
|
Apprentice Deity
|
|
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237

Time spent in forums: 4 m 8 sec
Reputation Power: 17
|
|
|
That means you have an error in the PHP of the css field.
|

April 17th, 2001, 02:39 AM
|
|
Junior Member
|
|
Join Date: Apr 2001
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Strange...
I add this in the php code
"$css = eval($row["css"]);"
and the css code in the database is "BODY {text-decoration: none; color: <?echo $fontcolor ?>; font-family: <?echo $font ?>; font-size: 9pt}"...
it doesn't seems wrong...^^"
|

April 17th, 2001, 07:52 AM
|
|
Apprentice Deity
|
|
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237

Time spent in forums: 4 m 8 sec
Reputation Power: 17
|
|
|
You can't use ECHO in it if you want to assign it to a variable. You also don't want the <? ?> tags. Change it to:
BODY {text-decoration: none; color: $fontcolor; font-family: $font ; font-size: 9pt}
Now when the line
$css=eval($row[css]);
is executed, $css will have the value $row[css] EXCEPT that the variables will be replaced with their values at the time the eval() is done, then you can echo $css
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|