Jump to content

HTML in MySql?


Drewdle

Recommended Posts

Is it possible to add HTML Code into a database using a hidden input?...

 

I want to add a hidden input to a register form so on the members list everyone has an automatic group display as 'Registered User' but I want the text in colour and the best way I could think of is to have

 

<font color=>Registered User</font>

 

inserted into the database, that way no matter where I display the group of a certain user its always the same colour, but obviously input is html so it just changes the colour of the value instead of including the html in the value.

 

How could I get around this?...

 

Not sure I explained that so well, lemme know if I didnt.

Link to comment
https://forums.phpfreaks.com/topic/224677-html-in-mysql/
Share on other sites

Are you talking about many different colors for the text or just one color for all?

 

Either way a better way I believe would be to have a definition file and include that on every page you want the text , heres an example

 

define.php

<?php
// define the common texts
define('REGISTER', '<font color="#FF0000">Registered User</font>');
?>

 

then on any particular page you want it

 

somepage.php

<?php
include('define.php');

echo REGISTER;
?>

 

you can echo that anywhere on the page you like as long as it is in php tags, you can also define all the site texts you want to use in more than 1 location in this file so you have a central place to edit the same text for every page.

 

But if you really prefer it is possible to put that into a database also, but will cost you a connection every time you use it

Link to comment
https://forums.phpfreaks.com/topic/224677-html-in-mysql/#findComment-1160558
Share on other sites

It already costs me a connection as the users group is also used to define access to set pages...

 

But that is a cool trick, I'll have to include it somewhere lol.

 

I have figure out a fix for my problem to, I just added the html before/after the variable in the insert query.

 

Thanks anyway!

Link to comment
https://forums.phpfreaks.com/topic/224677-html-in-mysql/#findComment-1160564
Share on other sites

Not sure if I understood your question but you could add a column with a name along the lines of 'hex', and associate hexadecimal codes with the names. Then when you want to write it you can do something like:

 


$query = "SELECT * FROM regUsers";
$result = mysql_query($query);
$n = mysql_num_rows($result);

for($i = 0; $i < $n; $i++) {
     $row = mysql_fetch_object($result);
     echo "<p style='color:" . $row->hex . "'>" . $row->name . "</p><br />";
}

Link to comment
https://forums.phpfreaks.com/topic/224677-html-in-mysql/#findComment-1160603
Share on other sites

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.