Jump to content

[SOLVED] Is there a way to do this? Change value from imported text


pcbytes

Recommended Posts

OK I have populated a database with information. On my site I pull a thumbnail picture in the database and the print CSS code in a text area that is associated with that picture.

 

Now my question is this. Lets say my database contains the following text information.

 

<style type="text/css">
body {
background-color: $color;
}
</style>

 

Then I pull in that CSS code to my textarea and display it to the screen with the code below... Problem is the output shows:

 

<style type="text/css">

body {

background-color: $color;

}

</style>

 

Is there a way I can pull that data from my database and have the $color variable filled?

 

Below is my code as it is right now it works with the exception of I have have no idea how to change the value $color in the text pulled in by $codes....... BASICALLY in a nutshell, I want my CSS code that is shown in the textarea box to be dynamic along with the entry I am displaying.

 

index.php

<!-- FORM TO DISPLAY DATABASE TEMPLATES -->
<form name="form1" method="post" action="<?php echo $PHP_SELF?>">
  <select name="section" size="1" multiple>
    <option selected>layouts</option>
  </select>
  <select name="category" size="1">
    <option selected>animals</option>
    <option>Anime</option>
  </select>
  <br>
  <input type="submit" name="Submit" value="Submit">
</form>

<?
//GET FORM DATA
$section = $_POST['section'];
$category = $_POST['category'];

//CONNECT TO DB
mysql_connect("localhost","jason","password");
mysql_select_db("test");

//GET DATABASE RESULTS BASED ON CATEGORY PICKED
$result = mysql_query("select * from upload where category = '$category'");

//FETCH SQL DATA AND PRINT IT TO THE SCREEN
while($row = mysql_fetch_array($result)){
$id = $row["id"];
$codes = $row["codes"];
print '<table width="400" border="2" cellspacing="0" cellpadding="0">';

//DISPLAY THUMBNAIL IMAGE FROM DATABASE
print ("<tr><td><img src=\"download.php?id=$id\"></td></tr>"); 

//POPULATE TEXTFIELD WITH CSS CODE FOR TEMPLATE
print "<tr><td><textarea name='textfield' wrap='OFF' cols='50' rows='7'>".$codes."</textarea><td></tr>";
print '</table><br /><br />';
}
mysql_close();
?>

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.