Re: Storing (html and php) Content in MySQL - help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 30, 2009 at 5:52 PM, Allen McCabe <allenmccabe@xxxxxxxxx> wrote:
> I have been trying to wrap my mind around how to accomplish this for a few
> days, and done estensive searching on Google.
>
> I know there are free CMS systems available for download, but I want to
> write my own code so I can maintain it and extend it, I need it to be
> customizable.
>
> So far what I have worked up is this:
>
> The mysql row contains a page_id field, title field, content field, and
> sidebar content field.
>
> in index.php:
> include("module.php")
> $username = findLoggedinUsername()
>
> eval ($content)
>
>
> in module.php:
> $result = mysqlquery("select * from content where page_id = get['id']")
> $row = fetcharray9$result)
> $content = $row['content']
> $title = $row['title']
>
> etc.
>
> The content mysql field contains:
>
> $ct = <<<END
> <p>Welcome $username, to the interweb</p>
> END;
>
> echo $ct
>
>
> In the heredoc, I can use variables like $username, but not like
> $row['username'].
>
> So far this method works just fine, however I want to be able to edit the
> content through the website itself. Am I on the right track or is this
> awkward? I am implementing a new, login system (mine isn't secure enough)
> and I want to implement it correctly.
>
> How should I go about storing content (which may or may not include php)
> into a page content field?
>

Use curly braces around the variable within the string when using arrays.
http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

echo "Hello {$row['username']}";

However, know that string variable parsing can be very inefficient and
consider this analysis of PHP internals in your design.

http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

On small sites with low traffic it doesn't matter much, but as
complexity and usage grows so does the overhead of writing your code
the "easy" way.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux