...

View Full Version : passing variables to mysql



eon201
11-15-2007, 09:42 AM
Ok so, here is my new problem.

My script works out a variable (the users ip) and then needs to pass it to a mysql table.
Quite simple.

But the trciky bit is that I need my php to run this style of script before it posts the data to the sql.

Does the table for this hour exist? y/n (there will only ever be one hour table which needs to be overwritten each hour)
Does the table for this day exist? y/n (there will be a new table for each day)
Does the table for this week exist? y/n (there will be a new table for each week)
Does the table for this month exist? y/n (there will be a new table for each month)

Create the corresponding table if neccesarry.
Post the data to the all the corresponding tables according to the time and date.

By doing this I am keeping all the tables amended and can pull them back into another php file which will read the data and post it accordingly.

Ok cool. I hope someone has done this before, as im quite unsure how to do this.

nikos101
11-15-2007, 11:29 AM
Does the table for this hour exist? y/n (there will only ever be one hour table which needs to be overwritten each hour)
Does the table for this day exist? y/n (there will be a new table for each day)
Does the table for this week exist? y/n (there will be a new table for each week)
Does the table for this month exist? y/n (there will be a new table for each month)



Do you not mean is there a value in the column for this "value" exist? Your going to have a load of tables otherwise.

aedrin
11-15-2007, 05:03 PM
I wonder why people do this?

Tables are not a good method of seperating data.

Read up on Database Normalization (http://en.wikipedia.org/wiki/Database_normalization). This should be natural to any DB developer.

nikos101
11-15-2007, 05:07 PM
I wonder why people do this?

Tables are not a good method of seperating data.

Read up on Database Normalization (http://en.wikipedia.org/wiki/Database_normalization). This should be natural to any DB developer.

I never quite understood well beyond the 5th form

aedrin
11-15-2007, 05:11 PM
I think only the first 2 or 3 normal forms are really important to know.

After that you get into more complexities which might not be as helpful (for small scale systems, at enterprise level this is not true).

nikos101
11-15-2007, 05:14 PM
Did you ever get into running concurrent databases on different servers for extreme uptime or for multiple processing power? I want to get there!

aedrin
11-15-2007, 06:00 PM
Nope, I haven't.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum