Jump to content

Archived

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

newmedia

mysql variable in the stylesheet ref??

Recommended Posts

Can anyone tell me.. is it possible to stick a mysql variable in the stylesheet reference in the header of a document or whould it have to follow the connect to database command further down the page?

call me crazy but,
i wanted to change the layout of a database record depending on its row $id.

Share this post


Link to post
Share on other sites
Sure, no problem... and if you post some code, someone might be able to show you how!

Share this post


Link to post
Share on other sites
[!--quoteo(post=353938:date=Mar 11 2006, 10:58 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 11 2006, 10:58 AM) [snapback]353938[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Sure, no problem... and if you post some code, someone might be able to show you how!
[/quote]



ok!
here's the code:

<html><head>

<link rel="stylesheet" type="text/css" href="../assets/<?php echo ($style) ?id=$id>">

</head> ^^^^not sure about this -------
<body>

<?php
include("../assets/dbinfo.inc.php");
mysql_connect(localhost,$username,$password)
or die( "Error! Could not connect to database: " . mysql_error() );

$id = $_REQUEST['id'];

// retrieve the row from the database
$query = "SELECT * FROM `people` WHERE `id`='$id'";

?>

_____________

and here's
the database:

table : people

fields: | ID | STYLE | NAME | SURNAME | etc...
-------------------------------------------
records: | 1 | style1.css | John | Smith | ....
-----------------------------------------
| 2 | style2.css | Tom | Jones | ......



it was something like that. I'm a real novice so may need more than a forum to save me but if you had any comments on whether mysql in the header will work that would be great.. anyone??



Share this post


Link to post
Share on other sites

×

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.