RE: [PHP-DB] Best way to store/retrieve content??
| From: | Peter Lovatt | Date: | Fri, 08 Mar 2002 00:39:02 +0000 |
| Subject: | RE: [PHP-DB] Best way to store/retrieve content?? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17558@lists.php.net to get a copy of this message | ||
Hi
I am not an expert but could XML be an answer?
The author(s) gets a screen designed by you, looking like the screen you
will publish, with type in text boxes (name="short_text1",
name="short_text2" etc )where the text will be. When you store the input
from the form you end up with
<article>
<pic1>pic1.jpg</pic1>
<short_text1>Short paragraph of text under pic1 </short_text>
<pic2>pic2.jpg</pic2>
<short_text2>Short paragraph of text under pic2</short_text2>
<long_text>lots of stuff, lots of stuff, lots of stuff, lots of stuff, lots
of stuff, </long_text>
</article>
which allows you to add any structure to the data, but store all the article
in a single searchable text field.
Otherwise maybe you could use two tables.
CREATE TABLE Article
(
ArticleID int(11),
Title char(50),
Start_date date default NULL,
End_date date default NULL,
End_actionID int(11) NOT NULL default '0',
Template_file varchar(50) ,
)
CREATE TABLE Article_components
(
ArticleID int(11),
Component_name char(50),
Content text
)
Article_components might contain :-
+----------+----------------+--------------------------------+
|ArticleID | Component_name | Content |
+----------+----------------+--------------------------------+
|123 | pic1 | pic1.jpg |
+----------+----------------+--------------------------------+
|123 | short_text1 | Short text etc etc |
+----------+----------------+--------------------------------+
|123 | pic2 | pic2.jpg |
+----------+----------------+--------------------------------+
|123 | short_text2 | Short text etc etc |
+----------+----------------+--------------------------------+
Which you could search and return the articleID, which you could then use to
retive the article in full.
To display, loop thro the result
<tr><td>$row["pic1"]</td><td>$row["pic2"]</td><td>$row["pic3"]</td></tr>
<tr><td>$row["short_text1"]</td><td>$row["short_text2"]</td><td>$row["short_
text3"]</td></tr>
Just a few thoughts
Be interested to know how you do this in the end.
Peter
-----------------------------------------------
Excellence in internet and open source software
-----------------------------------------------
Sunmaia
www.sunmaia.net
info@sunmaia.net
tel. 0121-242-1473
-----------------------------------------------
> -----Original Message-----
> From: Monty [mailto:monty3@hotmail.com]
> Sent: 07 March 2002 20:51
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] Best way to store/retrieve content??
>
>
> Hi Peter, thanks a lot for your advice. I think where I'm stuck is how to
> best store certain types of articles in a data table. Interviews would be
> easy, because it's just paragraphs of text with an inline photo here and
> there. The more structured articles are trickier and I can't
> figure out how
> to use the same Article table for all articles. Using the example
> I gave in
> a previous message, here's a rough page layout of one of these structured
> articles:
>
> +-----------+ +-----------+ +-----------+
> | image 1 | | image 2 | | image 3 |
> +-----------+ +-----------+ +-----------+
>
> Short paragraph Short paragraph Short paragraph
> of text under of text under of text under
> the image. the image. the image.
>
> +-----------+ +-----------+ +-----------+
> | image 4 | | image 5 | | image 6 |
> +-----------+ +-----------+ +-----------+
>
> Short paragraph Short paragraph Short paragraph
> of text under of text under of text under
> the image. the image. the image.
>
>
> If I have one field in the Article table for full_content (which
> works just
> fine for interviews), how could I enter the above type of article
> into this
> table so that the template will know to separate each element
> text block and
> match it up with the associated image? Is this a matter of
> writing a special
> parsing function that would take the following from the full_content
> field...
>
>
> <img src="image1.jpg">
>
> Short paragraph of text under the image.
>
> <img src="image2.jpg">
>
> Short paragraph of text under the image.
>
> ...and format break it down into an array so it can then be
> formatted on the
> page as illustrated above?
>
> My real block is how the set up the database more than the templates. As I
> mentioned, I'm trying to keep all articles in one data table so
> searches can
> be easily done on all articles.
>
> Thanks!
>
> Monty
>
>
>
>
> > From: pjln1@sunmaia.net (Peter Lovatt)
> > Newsgroups: php.db
> > Date: Thu, 7 Mar 2002 20:11:00 -0000
> > To: "Monty" <monty3@hotmail.com>, <php-db@lists.php.net>
> > Subject: RE: [PHP-DB] Best way to store/retrieve content??
> >
> > Hi
> >
> > I have done a similar thing, and found that you can store just
> the text in
> > the database.
> >
> > I added 'Short_content' which was a leader, and some other fields for
> > management.
> >
> > I designed a few templates in Dreamweaver and embeded a
> function to display
> > the content in the page
> >
> > eg <tr><td><?php print_content($ContentID) ?></td></tr>
> >
> > The function basically pulls the content from the database and
> prints it.
> > You can just print the text, or you can add HTML in the
> function to give a
> > particular layout. You can use the same principal to link
> images, or you can
> > hard code them into the page.
> >
> > If you want to be more sophisticated you can use a number of
> templates and
> > store the one to use in the record, giving.
> >
> > display.php?contentID=1234
> >
> > ->query db to get template for 'Article 1234'
> >
> > ->output 'template_1.htm' which has the correct layout, and the
> function for
> > this article embedded in it
> >
> >
> > CREATE TABLE S_content (
> > ContentID int(11) NOT NULL auto_increment,
> > Title varchar(100) NOT NULL default '',
> > Description varchar(250) default NULL,
> > Short_content text,
> > Full_content text,
> > UserID int(11) default NULL,
> > Start_date date default NULL,
> > End_date date default NULL,
> > End_actionID int(11) NOT NULL default '0',
> > Template_file varchar(50) ,
> >
> > PRIMARY KEY (ContentID),
> > KEY ContentID(ContentID),
> > )
> >
> > HTH
> >
> > Peter
> >
> > -----------------------------------------------
> > Excellence in internet and open source software
> > -----------------------------------------------
> > Sunmaia
> > www.sunmaia.net
> > info@sunmaia.net
> > tel. 0121-242-1473
> > -----------------------------------------------
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>