Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Sep 2009
    Location
    Greenfield, WI (U.S.A.)
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation script.php needs to create multiple files :/

    Ok so I am making (or at least trying to) a script that I will periodically run whenever (or whenever I chose) we add new items to our database. It wont be big but whenever we finish a project. (Backlot Imaging | Hollywood)

    I am just have a hard time figuring out how to even begin on this, I know I'm gonna have to use file_exists and such but I'm just scratching my head on how to loop it accordingly to output a correct result. All the pages are gonna be relatively the same. (hit projects and click a movie)

    So if you guys have any logical idea on the fwrite, fopen, etc. A little help even getting me started would be great.

    Thanks guys!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Are you saying that when you add a new project, you want to upload
    the photos, text, etc. and it gets added to a "database"?
    Then, each one of those projects is displayed using the database?

    Right now, it looks like each project is a static webpage (is that correct)?

    ==================

    You should use MySQL to store each project, but it could be done with a
    plain-text file (flat-file database).

    Every project page would be displayed dynamically using PHP,
    sort of like this: http://hollywood.backlotimaging.com?p=24

    The PHP script would look for the project ID of 24 and pull out the photos,
    descriptions, text, etc. for that project and render the page.

    Again, MySQL is the best option because it has great search capabilities
    and it's easy to manipulate data. But, you might have to hire a freelance
    programmer to get it done for you, if you don't know PHP very well.

  • #3
    New Coder
    Join Date
    Sep 2009
    Location
    Greenfield, WI (U.S.A.)
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No close, there will be no CMS backend to this. I will go into PHPMyAdmin and add all the values manually. I want to run this script and have it go.... "Hey wait a sec there is a new value in the database, let me create a page for it quick" and if certain pages already exist with it checking the database it will skip those.

  • #4
    Regular Coder
    Join Date
    May 2009
    Location
    Moore, OK
    Posts
    282
    Thanks
    11
    Thanked 41 Times in 41 Posts
    Quote Originally Posted by Randy53215 View Post
    No close, there will be no CMS backend to this. I will go into PHPMyAdmin and add all the values manually. I want to run this script and have it go.... "Hey wait a sec there is a new value in the database, let me create a page for it quick" and if certain pages already exist with it checking the database it will skip those.
    If you are using a CMS... once you tell a page it is in the database it should automatically be there... shouldn't it? Because most CMS run off of one index page and it uses the $_GET statement and most likely (i guess hopefully I should say) uses mod_rewrite to retrieve the page according to what matches a the database.

    So if you tell your CMS database that there is a new page by adding a new record then that page is already there.

    Code:
    -- Let's just say this enters with an id of 123.
    INSERT into Pages (url, name, title,......) VALUES ('new', 'page', ...);
    When you go to your browser:
    yoursite.com/index.php?page=new
    or if by id
    yoursite.com/index.php?page=123

    The page already is there. So I am a little confused on why if you are going to be using a CMS you would need to literally create a php page for the browser to find. If you could explain in a little more detail it would help, thanks.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    One PHP script displays the page for all items.
    There are no separate static pages.

    I guess I don't understand it either.
    The only files you need are "index.php", a MySQL database, and a directory with pics.

  • #6
    New Coder
    Join Date
    Sep 2009
    Location
    Greenfield, WI (U.S.A.)
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Writing dynamic pages is a big no no these days especially for search engines and stuff. It's all gonna be dynamic so example;

    movie1.php (in the database)
    movie2.php (in the database)

    movie3.php (NOT IN DATABASE)

    So I would run script.php it would be like oh.... ok 2 pages exist it looks like there is a new row in the database for another movie. Let me run my script to auto generate a page for it.

    I hope that helps? :[

  • #7
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,294
    Thanks
    4
    Thanked 203 Times in 200 Posts
    Quote Originally Posted by Randy53215 View Post
    Writing dynamic pages is a big no no these days especially for search engines and stuff.
    Why do you believe it a be a big "no no" and what evidence do you have that search engines really care about URLs (other than what SEO companies tell you to try and sell their services)?
    Dave .... HostMonster for all of your hosting needs

  • #8
    Regular Coder
    Join Date
    May 2009
    Location
    Moore, OK
    Posts
    282
    Thanks
    11
    Thanked 41 Times in 41 Posts
    Dynamic pages are used all the time. The only reason search engines would have a problem with them is if you do not use a mod_rewrite...

    If your url is
    example.com/index.php?page=test

    Then yes some search engines have problems because they stop checking after the question mark (?).

    But if you use mod_rewrite and your url is
    example.com/test

    Then no search engine would have a problem with it. It is actually recommended by many if not most professional designers that you use mod_rewrite to make your site as user friendly as possible... ei no question marks in url.

  • #9
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,294
    Thanks
    4
    Thanked 203 Times in 200 Posts
    Quote Originally Posted by Coyote6 View Post
    If your url is
    example.com/index.php?page=test

    Then yes some search engines have problems because they stop checking after the question mark (?).
    What leads you to that conclusion? Do you have evidence to back up that statement?
    Dave .... HostMonster for all of your hosting needs

  • #10
    New Coder
    Join Date
    Sep 2009
    Location
    Greenfield, WI (U.S.A.)
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "We live in an era where we don't have to write as short as possible code any more. Nowadays, code is better off being readable and understandable by other programmers, and even yourself if you haven't touched it in a while. Standardization is important, especially when you commonly work with other people on a project"

    And regardless this isn't a what is logical these days and what isn't everyone has there own sense of coding and that is normal. Can we get back on topic please.

  • #11
    Regular Coder
    Join Date
    May 2009
    Location
    Moore, OK
    Posts
    282
    Thanks
    11
    Thanked 41 Times in 41 Posts
    Quote Originally Posted by djm0219 View Post
    What leads you to that conclusion? Do you have evidence to back up that statement?
    Just google it and there are lots of sites that talk about it.

    Here's the first one from my search.
    http://www.sitepoint.com/article/dyn...eo-tips-hints/

    I originally learned all of that from my e-commerce programming book.

    Okay back on topic.... what was the topic again?
    hehehe joking.

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Take one of your pages that you need, view the HTML and copy/paste to Notepad.
    Save that as "template.txt" (plain text file). Your "template.txt" file is only used as
    the base template from which to build each actual page.

    Now, a PHP script can open that text file and read it line by line (into an array).
    The PHP script can interject the proper image links and text where needed.
    It then writes the array back to a file of your own choosing, such as
    "CrossingOver.php". That new page is saved with all of the other pages.

    "template.txt" remains untouched ... PHP only reads from that file.

    That's how you would do it using PHP.

  • #13
    New Coder
    Join Date
    Sep 2009
    Location
    Greenfield, WI (U.S.A.)
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's mlseim that seems like the most logical way, I just wanted to see other peoples opinion on the matter, I appreciate it.

    Thanks to all for contributing.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •