Welcome to WebmasterWorld Guest from 54.166.54.215

Forum Moderators: coopster & jatar k

DB Table or fopen

Begginers advice

   
5:41 pm on Oct 8, 2009 (gmt 0)

5+ Year Member



I've got a page on my site that displays 8 rows of data from a recordset at a time and paginates to the next/previous 8 accordingly.

I want to be able to control the number of records displayed per page on the backend CMS page where I add/edit entries in the database, and I'm wondering if it's necessary to set up and entire table in the DB for that one value or if I should do something like set up a simple text file with the value in it that is opened and edited with the file functions like fopen, fwrite, and such.

I feel like there is probably a very simple way to do this and I'm going the long route here.

6:14 pm on Oct 8, 2009 (gmt 0)

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Personally, I'd probably go with the table, just because it provides so much ease of use / flexibility as you wish to add other setting or controls the displaying the DB results...
7:22 pm on Oct 8, 2009 (gmt 0)

5+ Year Member



OK, that's kind of what I was thinking but thought maybe there was something i wasnt thinking of.
7:30 pm on Oct 8, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'm wondering if it's necessary to set up and entire table in the DB for that one value or if I should do something like set up a simple text file....

If this is your only value, text is fine - however - if you have an administrative back end, you are very likely to have at least a few and should have a LOT of configurable variables.

Some examples,

- per_page (the one of which you speak)
- Page titles - what if the owner wants to change their shopping cart heading from "Shopping Cart" to "Shop for Widgets?" And . . . they don't know how to, or you don't want them futzing around with, the HTML/PHP?
- Owner email, for responses, email functions . . .
- company name, number, address for display in various places . . .
- CSS selector names used by your scripts, so these can be changed if the owner experiments with different styles

You get the picture. One of the biggest problems I have with most existing code I'm asked to "fix" - nearly all of it has hard-coded values in places that should be variables that are either set at the head of a global include or extracted from a database.

If you extract them from a database, they become configurable, if they are configurable, your project is portable . . . . and you can see where that goes.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month