Help with Super Simple CMS

Hi everyone,

This is my first post here so please be gentle. :wink:

What I need to do is so simple that I couldnt find one example on the web that I could learn from. I don’t have the time to actually start to learn PHP/MySQL right now as I have a deadline to get this done by but once this little project is outta the way I am definitely going to start studying this! Anyway, here’s what I’m after:

I need to be able to allow another user to change some text on a web page on a daily basis.
They would do this by accessing an unpublished page that I would give them the URL to (no login required - I want to keep this as simple as possible).

Once there they would enter the required data into a form, click submit and the new data would appear on the web page, replacing what was already there.

I’ve already created a MySQL table with 1 row and 5 fields. I’m not using an id field as their won’t be any additional rows added. The data will only be updated/changed. I used varchar or char for them but I’m sure that is a mistake.

Here is a graphic of what the area I want to edit looks like. I only want to change the highlighted data: date, numbers under the years, the percentage, and the number of murders in last 24 hours. (this is for a police site). If anyone wants to, maybe they can go one step further and share how might be able to have the proper arrow graphic (up or down) appear next to the percentage based on its value (negative/positive).

Is this simple or am I just too stupid to know?

Hope someone can help me out on this.

David

What you can do is work out which values are really required in the database. Currently you have the following fields:

  • date
  • 2008
  • 2007
  • percent
  • last24

That’s all nice 'n dandy, but what is ‘date’ really used for? Displaying ‘today’s date’? Take that field down (if you’re not gonna use it for logging the numbers on a per-day basis) and use the date() function instead ;)

Next is ‘percent’. Why store that in a database, when it’s a piece of cake to have PHP calculate it realtime for you? Again, only remove if you’re not using it for logging purposes.

This would leave you with the following fields:

  • 2008
  • 2007
  • last24

To define the arrow is very simple: if the number of 2008 is below the number of 2007, down arrow. If it’s equal, no arrow (or whatever placeholder you have). If it’s above, up arrow:

$arrow = "equal.jpg";

if ($sql_result['2008'] < $sql_result['2007']) {
  $arrow = "downarrow.jpg";
} elseif ($sql_result['2008'] > $sql_result['2007']) {
  $arrow = "uparrow.jpg";
}

Thanks for the reply zyppora,

The date field is not the current date and will vary
depending on weekends, holidays, etc…but,

You are absoluteley correct regarding the percentage
though, that should be a calculated value and doesn’t
need to be in a database. Thanks for pointing that
out.

Thanks for the syntax on the arrow too.
That will come in very handy. :)

David

Sponsor our Newsletter | Privacy Policy | Terms of Service