By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,316 Members | 2,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,316 IT Pros & Developers. It's quick & easy.

Using PHP & MySQL to display web pages

P: n/a
AF
I am a real novice to php and MySQL, with about a week's worth of
reading and self tutoring. I have an urgent need to publish a
database of information and need some guidance on how to do this.

This question might be more suited to a MySQL newsgroup, but since php
and MySQL seem to have become almost married to one another, and since
getting the data out and displaying it is where my problem seems to
lie, I thought I would start with this php group.

The problem is I can not figure out how to put information into a
MySQL database and get it out and correctly dislay it for the web.
More correctly I have two types of data I need to get in and out.

1. I have some web page content, not inlcuding borders, that is in
html format. So I have tried saving the html code, which looks
exactly like the code when you "view source" on a web page, into MySQL
and getting it out. I can get it out, but I have not figured out how
to make it act like html, i.e. to be interpreted by the browsers.
Instead it comes out looking exactly like html code. It is not being
interperted by the browser.

2. I would prefe instead of typing in html code for the content of a
page to type in instead the text, tables, lists, etc. Here is where
my problem lies, how do I input to MySQL relatively simple web pages
that may have a table, a list, some links, a picture?

3. How do I call up and use the data from MySQL an dget this to
display for the web?

By the way, I have been learning css, so I would like to use this if
possible. If not, i.e. if the formating mechanism for getting content
into a database precludes having it formattted by css on the
publication sie, then that is ok. I can live with that.

Thanks for any help

Cheers to everyone,

Al

http://www.discountdrivingschool.com
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
I noticed that Message-ID: <bj********************************@4ax.com>
from AF contained the following:
1. I have some web page content, not inlcuding borders, that is in
html format. So I have tried saving the html code, which looks
exactly like the code when you "view source" on a web page, into MySQL
and getting it out. I can get it out, but I have not figured out how
to make it act like html, i.e. to be interpreted by the browsers.
Instead it comes out looking exactly like html code. It is not being
interperted by the browser.
It most certainly should be. I'm afraid we need code to see what you
are doing wrong. Are you saving the file with the extension .php?
2. I would prefe instead of typing in html code for the content of a
page to type in instead the text, tables, lists, etc. Here is where
my problem lies, how do I input to MySQL relatively simple web pages
that may have a table, a list, some links, a picture?


Usually PHP is used to populate an existing table (or generate a dynamic
table) from data stored in a database. Pages can consist of html parts
and PHP parts but when the server has finished the PHP is processed and
only the output gets sent to the browser.

e.g.

<html>
<body>
<?php
print "Hello World";
?>
</body>
</html>

is sent to the browser as

<html>
<body>
Hello World
</body>
</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
AF <bs********@NOSPAMYahoo.com> wrote in
news:bj********************************@4ax.com:
I am a real novice to php and MySQL, with about a week's worth of
reading and self tutoring. I have an urgent need to publish a
database of information and need some guidance on how to do this.


I am quite new myself. php.net has alot of tutorials. mysql really isnt
that hard, except for the admin stuff, which I think is a pain. But
phpmyadmin helps alot, and its free. Installing it takes a little care...
its not like installing photoshop. But follow the instructions and it will
work. Later, you can write your own simple HTML form pages with php so you
can do simple editing of tables.

You do have apache, mysql, & php I assume.

And yes there is alot of info in the SQL newsgroup.
Jul 17 '05 #3

P: n/a
AF
On Mon, 10 May 2004 00:24:03 +0100, Geoff Berrow
<bl******@ckdog.co.uk> wrote:

snip..
Usually PHP is used to populate an existing table (or generate a dynamic
table) from data stored in a database. Pages can consist of html parts
and PHP parts but when the server has finished the PHP is processed and
only the output gets sent to the browser.


Let me give you an example of what I want to do:

here is a url:

http://www.improvingyourhome.com/homestore.nsf/32a793ea58ba3df585256e5c005f5f66/f348bc1ba98fa17685256e59005cbc58!OpenDocument

If you go look at it, you will see a list in the middle of the page.

Here is the page without the <li>

Abundant Earth offers a wide variety of environmentally sensitive
products and services for people who want to make a difference in the
world.

Departments include:

Air Purification
Bags & Packs
Beds & Bedding
Candles - Holders
Cards - Journals
Children - Fun
Cleaning
Coffees & Teas
Energy Savings & Conservation
Gifts & Crafts
Health Wellness
Hemp & More
Home Furnishing
Jewelry
Kitchen & Bath
Lawn & Garden
Personal Care
Pets & Wildlife
Platform Beds
Recycled Items
Vitamins & Supplements
T-Shirts
Water Purification
The list starts at "Air Puritfication".

Now I think I can solve my other problem in my original post. I am
sure there is something I have done wrong.

But getting a page's content that contains a list like the above or a
table is not shown, or at least I can't find it.

Imagine for example you were to create a simple Word doc that
contained a list and a table, and now you want to show that Word doc
on the web as an html page. But you want the contents of the Word doc
to be in a field and then have that field displayed.

Is there something like a "rich text field" in MySQL and can php
display this field in html?
Cheers to everyone,

Al

http://www.discountdrivingschool.com
Jul 17 '05 #4

P: n/a
In article <4i********************************@4ax.com>, AF wrote:
Let me give you an example of what I want to do:

But getting a page's content that contains a list like the above or a
table is not shown, or at least I can't find it.


If i understand you right: You have a page in your database. That page
itself has a list that should be built dynamically.

In that case you might want to have a look at the eval function in the
manual.
--
http://home.mysth.be/~timvw
Jul 17 '05 #5

P: n/a
In message <4i********************************@4ax.com>, AF
<bs********@NOSPAMYahoo.com> writes
<snip>

Is there something like a "rich text field" in MySQL and can php
display this field in html?
There are a variety of text fields in MySQL, but none of them are the
kind of 'rich text' field you want. You would have to populate them
with the correct HTML to produce the result you wanted in the browser.

See:
http://dev.mysql.com/doc/mysql/en/Column_types.html
http://dev.mysql.com/doc/mysql/en/String_types.html
http://dev.mysql.com/doc/mysql/en/CHAR.html
http://dev.mysql.com/doc/mysql/en/BLOB.html
I would expect your PHP page to generate some of the required HTML and
extract some parts from the database, so to generate a list it would
contain:
<ul><li>1st tiem</li><li>second item</li></ul>

And you would have to type in (or otherwise generate) the correct tags
yourself.

At the end of the day the PHP script has to generate the complete HTML
that you would write to produce the desired page. It can do that by a
mixture of bits of HTML in the PHP script outside the <? ?> sections
(e.g. the sections that contain the PHP code), bits of HTML that are
printed as literals inside the <? ?> sections, and bits of HTML that are
extracted from a database again inside the <? ?> sections.

Cheers to everyone,

Al

http://www.discountdrivingschool.com


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #6

P: n/a
AF
On Mon, 10 May 2004 08:56:20 +0100, Five Cats <ca*******@[127.0.0.1]>
wrote:

snip...

There are a variety of text fields in MySQL, but none of them are the
kind of 'rich text' field you want. You would have to populate them
with the correct HTML to produce the result you wanted in the browser.


You have an accurate picture of what I want to do. How do really big
sites, like About.com, input all of their articles? I can see how to
handle pictures, but what about tables and lists that are part of my
page content?

Do they use languages that do have this kind of field? Or do they
just input the code for the whole content?

In the example I posted:

"Abundant Earth offers a wide variety of environmentally sensitive
products and services for people who want to make a difference in the
world.

Departments include:

Air Purification
Bags & Packs
Beds & Bedding
Candles - Holders
Cards - Journals
Children - Fun
Cleaning "

is there a way to post this with a pseudo html, something like this:

"Abundant Earth offers a wide variety of environmentally sensitive
products and services for people who want to make a difference in the
world.

Departments include:

<li>Air Purification
<li>Bags & Packs
<li>Beds & Bedding
<li>Candles - Holders
<li>Cards - Journals
<li>Children - Fun
<li>Cleaning "

The point being that a paragraph needs no code to be rendered
properly, but the list of items does.

This would be doable from an input point of view. But if I had to add
the <br>'s and other code in order to render the whole page that would
be very inefficient.

What about all of these content management systems I see? They have
fields that allow bold, italics, centering, fonts changes in size and
color. How do they handle the code?

Do they convert the field I would input into html and then save it?

Thanks to everyone that has posted.

Cheers to everyone,

Al

http://www.discountdrivingschool.com
Jul 17 '05 #7

P: n/a
In message <ej********************************@4ax.com>, AF
<bs********@NOSPAMYahoo.com> writes
On Mon, 10 May 2004 08:56:20 +0100, Five Cats <ca*******@[127.0.0.1]>
wrote:

snip...
There are a variety of text fields in MySQL, but none of them are the
kind of 'rich text' field you want. You would have to populate them
with the correct HTML to produce the result you wanted in the browser.


You have an accurate picture of what I want to do. How do really big
sites, like About.com, input all of their articles?


I can't say as I can only see what they produce.
I can see how to
handle pictures, but what about tables and lists that are part of my
page content?

Do they use languages that do have this kind of field? Or do they
just input the code for the whole content?

In the example I posted:

"Abundant Earth offers a wide variety of environmentally sensitive
products and services for people who want to make a difference in the
world.

Departments include:

Air Purification
Bags & Packs
Beds & Bedding
Candles - Holders
Cards - Journals
Children - Fun
Cleaning "

is there a way to post this with a pseudo html, something like this:

"Abundant Earth offers a wide variety of environmentally sensitive
products and services for people who want to make a difference in the
world.

Departments include:

<li>Air Purification
<li>Bags & Packs
<li>Beds & Bedding
<li>Candles - Holders
<li>Cards - Journals
<li>Children - Fun
<li>Cleaning "

The point being that a paragraph needs no code to be rendered
properly,
Possibly - but see the comment on CSS below.
but the list of items does.

This would be doable from an input point of view. But if I had to add
the <br>'s and other code in order to render the whole page that would
be very inefficient. What <br> would that be?

Departments include:
<ul>
<li>Air purification</li>
etc.
</ul>

The tags have to be there in the final analysis.

What about all of these content management systems I see? They have
fields that allow bold, italics, centering, fonts changes in size and
color. How do they handle the code?

Do they convert the field I would input into html and then save it?
Have never seen or used one so cannot comment, but I'm sure that style
sheets are part of it as well so that it's easy to alter the style of a
given type of element without having to alter all the pages or whatever.

They might be storing the stuff as XML and doing things to it on it's
way out.

There are lots and lots of ways of doing things, so as the questions get
more & more detailed it gets harder & harder to provide answers as what
comes into my head are more & more questions.... ;-)

Thanks to everyone that has posted.

Cheers to everyone,

Al

http://www.discountdrivingschool.com


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.