XRS Posted September 16, 2013 Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/ Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 Why are you storing your markup in the database in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449690 Share on other sites More sharing options...
XRS Posted September 16, 2013 Author Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449693 Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449694 Share on other sites More sharing options...
XRS Posted September 16, 2013 Author Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449699 Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 Yeah, well its not really something I think you'll implement all that cleanly so... I'm not sure its the best design decision. I mean, markup in the database, just seems very dirty to me. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449705 Share on other sites More sharing options...
vinny42 Posted September 16, 2013 Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449733 Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449777 Share on other sites More sharing options...
vinny42 Posted September 17, 2013 Share Posted September 17, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449807 Share on other sites More sharing options...
XRS Posted September 17, 2013 Author Share Posted September 17, 2013 Yeah thanks. I think I already got a simple solution that can do the same thing, but not totally editable from admin backend. But thats not really a problem. Thanks all of you. Quote Link to comment https://forums.phpfreaks.com/topic/282184-mysql-output-inside-mysql-output/#findComment-1449810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.