Jump to content


Photo

mysql variable in the stylesheet ref??


  • Please log in to reply
2 replies to this topic

#1 newmedia

newmedia
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 11 March 2006 - 03:22 PM

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.



#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 11 March 2006 - 03:58 PM

Sure, no problem... and if you post some code, someone might be able to show you how!

#3 newmedia

newmedia
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 11 March 2006 - 04:41 PM

[!--quoteo(post=353938:date=Mar 11 2006, 10:58 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 11 2006, 10:58 AM) View Post[/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??








0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users