Jump to content

HTML/MySQL


Yamaha32088

Recommended Posts

How would I setup my database tables/fields/rows etc, to allow me to be able to add html into a row and query it so that it displays on a php page as working html. Basically what would the row have to be set up as like VARCHAR 255, ASCII, Not NULL. I am very unfamiliar with MySQL so all help is appreciated.

Link to comment
Share on other sites

i guess the solution you are thinking about would be slower and more complicated than simply

stick the tags by echoing them to output before and after you retrieve values.

having sd that, however if  you were to write scripts such as get_linktag() and write such stuff

then retrieving it from a column defined as varchar(35) with some html in that column would work.

 

CREATE TABLE `html_t` (

  `id` int(11) NOT NULL auto_increment,

  `name` varchar(35) default NULL,

`value` varchar(35) default NULL,

 

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM AUTO_INCREMENT=206 DEFAULT CHARSET=latin1;

 

then insert into the table names and values

such as

insert into html_t ( name, value) values

  ('bold1', '<b>' );

insert into html_t ( name, value) values

  ('bold2', '<\b>' );

 

insert into html_t ( name, value ) values

  ('doctype_transitional', 'bla bla bla');

 

 

of course you wouldn't want to put deprecated tags in there! and you would have to measure the longest

string and continually do an alter table to get the largest string in place. You would be wasting space

but not much over all...

in case you have to extricate a quote or tick mark you might have to back slash the value

when  you insert it into the database so that it goes into the database without an error.

hth

 

 

 

 

Link to comment
Share on other sites

Thanks for the quick reply maybe I am not going about building this the right way. Basically the client wants a database of business all over the US, he wants to have them be able to search by category, state, zip, ETC. I have got the search function and everything working and the database to my liking for now, but for each business the client wants them to have detailed information about themselves and be able to pick out a background color select text color possibly a background image and of course a link to their website. Real basic HTML stuff there is a possibility of having thousands of businesses in the database and rather then create a separate page for each customer and upload it to a folder with a name, I figured it would be easier if I was to add a column that had a little bit of HTML inside of it with their description and link, then be able to echo it out into a PHP page. Does this sound like a good idea or just a dumb one. If you think this is the right way to go how would I have to create the database. I understood about 40% of what you wrote above haha ;D

Link to comment
Share on other sites

Depending on what version of MySQL version, using this before inserting the variable should let you put HTML into the DB:

 

$html = "<b><div>etc...</div></b>";

$html = mysql_real_escape_string($html,$conn);

 

And then just insert the $html variable into the DB as usual. This should work.

Link to comment
Share on other sites

so as i understand it now, what you really want to do is to allow a client to create their own html page, with style.

so you ultimately want the php to pull out of the database the style code, and write the html page.

if you had the user choose the style from a pull down list or color picker his selection would be inserted into a style column(s)

with his id. then when he is online the php would have either written the style inline to the  html page or pulled out and written a css style sheet and have the page attached link written into the html page...

but in order to have the images be where he wants them to be, you need to have pre-determined layouts otherwise his text will

possibly overrun the image. so i guess you already have a layout now? and he selects where the image will go ( header, sidebar, in the maincontent area?).

i think what you want to do is to present a few templates and have them pick one, and write which one he picked to the database and always present that to the page. Then have him style it, with more select pull downs, write the style sheet to a TEXT column and on the fly insert that inline to the template page by some sort of substitution mechanism.

does that make sense???

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.