Jump to content

mysql output inside mysql output


XRS

Recommended Posts

Hello,

 

I need help with one thing, that relies in how to insert dynamic data in a middle output in something from database. A simple example could be:

 

<div align="SOMETHING">blah blah</div>

 

Basically i want to have a field in my database with the div, and another one with the align settings (center, rigth...) . Now, in the output, how can output the align inside the ouput of the div?

 

This is a basic example because there are more things to rule (size, color, position) so its not good to paste the code in html and then only the specs(color,position) by datase output.

 

Can anyone help me getting there because Im having some problems doing so?

Thanks.

Link to comment
Share on other sites

As I said, its a simple example because my final code is not static. I want to easily manage all data from an admin backend. For example I want a user to choose a color and ill use that user color, but my html code, isnt always the same, changing position, size etc.. so if I have 1000 colors, positions and sizes, I cant store them all in database and choose thr rigth one to display, being an never ending task.

Link to comment
Share on other sites

Still, markup in the database smells bad, but anyway....

 

It sounds more to me like you need to add classes to your markup, and then create a means to generate your css dynamically. Its a much simpler solution that results in the same sort of end result. It should be pretty simple to create an interface to edit css.

Link to comment
Share on other sites

Ive been searching about that, but for example if I want (another example ) of making an adsense revenue sharing website? There are colors sizes and many publishers ids.. I dont think that with classes it,could be a good thing, because my template have colors (that i can change dinamically without change all template) and ad size will be diferent for any kind of dinamic content.

Link to comment
Share on other sites

What's so dirty about storing HTML in a database? If it was PHP code in a database then yes, that's dirty, really dirty.

 

Anyhow, using MySQL you'd have to create a table that holds the HTML, and a linked table that holds the names of  the placeholders that can be replaced and probably some information about what they can be replaced with.

Then you have to fire a few queries to gather data for each placeholder and do the replacing in PHP.

 

MySQL doesn't let you do this using just it's own features, unles you create a stored procedure, which probably takes more time to learn and debug than to create the solution in PHP.

Link to comment
Share on other sites

What's so dirty about storing HTML in a database?

Its harder to edit and debug for one. Most people decide to use the right tools for the job, that includes editors capable of handling html well. Storing your markup in a database removes these tools from the equation.

 

Besides, I really don't see any need to store anything but the most simple markup in a database. Markup is part of your application, not part of your data.

Link to comment
Share on other sites

 


Most people decide to use the right tools for the job, that includes editors capable of handling html well. Storing your markup in a database removes these tools from the equation.

 

True, but only for that part of the HTML that is required to make the application work and is maintained by the developer. HTML that the cliens add's through the application requires a wysiwyg editor in the browser it as a file unnecessary, possibly even undesirable because it would require strict synchronization of the files on disk.

 

Anyway, we agree that regular HTML that is a structural part of your website is better stored in a file, because it is easier to manage.

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.