# Can i do this with PHP/MySQL?

**URL:** https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220
**Category:** programming
**Created:** [September 14, 2004, 9:27am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220 "2004-09-14T09:27:51Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![red\_A](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@red\_A](https://forum.kirupa.com/u/red_A)
#### Post date: [September 14, 2004, 9:27am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/1 "2004-09-14T09:27:51Z")

</div>

Store webpages in a database, including all the links and images, and have them be retrevied from a database using php???

also what would the advantage of that be??? – i was told by a friend that i could do that, but im having truble understanding why i would need it!~

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 11:09am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/2 "2004-09-14T11:09:41Z")

</div>

well you could make an online entry for all pages so that the client / admin doesnot have to use ftp to make changes. like a cms

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 11:26am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/3 "2004-09-14T11:26:11Z")

</div>

you could use a template system to store all the HTML then write the templates with PHP. The advantage of this is you can have dynamic data in different parts of the templates…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 1:25pm UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/4 "2004-09-14T13:25:42Z")

</div>

You can store all the webpages in different files. Then code a file that would create new pages or edit existing pages. ( easily done usign file handling functions. ). files\_get\_contents the files and put them into a input field to edit them.

Saving them into a database would be franking saying, a waste of time. Your webpages are so large, you could do better saving them in flatfiles.

The advantage would be that you can edit your files without using ftp…

That’s my opinion of course.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 2:07pm UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/5 "2004-09-14T14:07:06Z")

</div>

Thank you! I guess it’s no no!!! Ok another stupid question,…besides being able to make a connection to a mysql database _which i have done_ is there a way to creat tables using dreamwaver mx2004?? or this should only be done with applications like ems mysql manager, phpmyadmin, or just plain dos CLI???

Thank you!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 11:15pm UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/6 "2004-09-14T23:15:42Z")

</div>

Just a extra tip. u should not add php code in the pages that u retrieve from the database!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 1:25am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/7 "2004-09-15T01:25:19Z")

</div>

Avoid stuffing your database full of html code. Use the database to store a link to an external file. PHP has plenty of functions to allow the reading and writing of any sort of document so you can still make the changes you need to on the fly with a bit of creative programming. Your database will thank you.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 1:31am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/8 "2004-09-15T01:31:38Z")

</div>

I agree, if you are going to use a database at all use it for storing the links the external files.  
Here is a script i wrote up for editing a .txt file with PHP, they might be usefull for you…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 4:04am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/9 "2004-09-15T04:04:28Z")

</div>

I disagree with the last option and code. if u want to edit files… better to use some kind of interface that edits and updates the database. instead of using textfiles or whatever.

Unless ure not so familiar with using db.s that r / w files might be an easyser option but never is the better option.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 4:07am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/10 "2004-09-15T04:07:28Z")

</div>

Referring to text that is… use like a default template / or body page and include the text fetching it from a database.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 5:39am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/11 "2004-09-15T05:39:57Z")

</div>

> [@ol4pr0](#):
>
> I disagree with the last option and code. if u want to edit files… better to use some kind of interface that edits and updates the database. instead of using textfiles or whatever.
> 
> Unless ure not so familiar with using db.s that r / w files might be an easyser option but never is the better option.

It’s a bad design if you need to start sticking html pages into the database. Good design principles and common sense should tell you to keep as little html information in the database as possible. I think you might be confusing what he is asking. Never stick an entire html page in a database unless you have to… it’s wasteful and will slow down the database retrieval times.

Rehashing on the template thing again: depending on what you need to do with the site you can store text etc in the database and use PHP to retrieve the information and populate a html template with the dynamic content (like the way vBulletin operates).

Reading and writing files is a better option than putting the whole page in the database… not better than populating a html template with database information.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 9:11am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/12 "2004-09-15T09:11:24Z")

</div>

Hey thank alot you guys! this is excellent info!! 🙂 and thanks for the file read and write code…i’m going to take a closer look at how i could use that, since im going to want to make my Intranet (@ Work) dynamic, the whole thing that im trying to achive is, i have a Intranet site at work, that i maintain and create content for, but now it’s become BIG! with a few hundred documents, photos, news articles, archives of news articles, and it’s becomeing more and more difficult to maintain, so i want to take a big step into moving some of the content into a database, say pics, articles in docs and pdf’s…and add scripts to the sections of our site, that would retrive the selected file from a database upon loading…i think that’s dynamic??? I would appriciate some help or any suggestion at all, as to how i could go about make the site more managable??

Thank You

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 4:40pm UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/13 "2004-09-15T16:40:31Z")

</div>

Are you saying you want the user to be able to download different files depending on what they want?  
Well for that you would want to use a MYsql database,  
just have all the files in a database in different rows,  
then just a query string on the end of the .php page and depending on what the query string value is you can have code that will retrieve the correct path to the file off the database so the person can view/download the file.  
If you dont know a querystring is a variable attached to the end of the URL, like this:  
somepage.php\*\*?file=somerownumber\*\*  
you can then retrive that varibal in the php code by doing:  
$querystring = $\_REQUEST[“file”];

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 11:41pm UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/14 "2004-09-15T23:41:46Z")

</div>

> [@red\_A](#):
>
> I would appriciate some help or any suggestion at all, as to how i could go about make the site more managable??

Content management systems are difficult to create so it’s probably just best to ask the questions as they come up. With a large scale site you’ll need to invest some time learning a template system (phplib’s template class is what I use, but smarty templates and fast template are apparently very good). It’ll save you alot of time down the track.

Another suggestion is to build all common site functions into classes (eg. file uploads, image manip, pagination). Also, put all your common variables and settings into 1 file so you can easily make global changes. I use an \*.ini file and php’s parse\_ini\_file() function to retrieve variables.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 17, 2004, 7:58am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/15 "2004-09-17T07:58:10Z")

</div>

sorry i dont think i understand you ironikart!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 17, 2004, 11:53am UTC](https://forum.kirupa.com/t/can-i-do-this-with-php-mysql/64220/16 "2004-09-17T11:53:48Z")

</div>

mmm… might be best to learn the basics first then. Learn classes, functions and study up on php’s inbuilt functions. Once you’ve got a fair idea on how php works the rest kind of falls into place.
