Liam Mackenzie wrote:
> Hi,
> I was wondering what you would do in this situation...
> I have a form, with 196 fields that I need entered into a database.
> But the form and it's contents need to be changed every day,
> and I need to store the old data in an archive so it can be accessed
> at a later date.
> That means that after a week, I'm going to have a tonne of data.
> Catch is, this form will be used every day for about 3 years.
> I'm pretty certain MySQL can handle it, but I need to know, what
> would be the best way to store this data?
> I've set up a calendar, that will take the user to a different version
> of the form every day.
> Accesible here:
> And the form I'm talking about is here:
> Here's a copy (minus passwords) of my form...
> I'm sure that there's a better way to do it...

I'm sure there is too... :)

Have you any experience with arrays?

PHP can accept data from the form in the form of an array, so you can
build your form and process it with many fewer lines than you have (and
modify things much easier).

If, for example, the club opened at 5:00 am in the future instead of 6,
you'd probably have to go change that big huge SQL statement, and add 
more lines to the code, right?  If you build with arrays, and smartly,
you can avoid much of the work you're doing.

BTW - the 'smartly' thing isn't to imply you're not smart.  I'm simply
saying there are techniques to make this stuff easier, and once you
know them, you won't go back, and you'll work faster.

I'd probably make each time/date a separate entry in a table, so each
day would have 196 entries, instead of one row having 196 columns, which
you seem to be doing.

$startkey = 600;
$starttime = (5 * 3600); // EDT is 5 hours behind GMT, so we get 
ourselves to midnight
$starttime = $starttime + (3600 * 6) ; // start off at 6 hours into the 
$endtime = $starttime + (3600 * 18) ; // end 18 hours in the future
?> <table> <?
while ($starttime < $endtime) {
$time = date("h:i A",$starttime);
$x = date("Hi",$starttime);
  <td><b><font size="2"><?=$time;?></font></b></td>
        <td><input type="radio" name="fs[<?=$x;?>]" value="fw">
        <input type="radio" name="fs[<?=$x;?>]" value="sp"></td>
        <td><input type="text" name="num[<?=$x;?>]" size="4"></td>
        <td><input type="text" name="sur[<?=$x;?>]" size="8"></td>
        <td><input type="text" name="giv[<?=$x;?>]" size="8"></td>
                <select size="1" name="apt[<?=$x;?>]">
                        <option selected value="1">1
                        <option value="2">2
                        <option value="re">Re
        <td><input type="text" name="ph[<?=$x;?>]" size="8"></td>
        <td><input type="checkbox" name="c[<?=$x;?>]" value="ON"></td>
$starttime = $starttime + 1800;
<input type="hidden" name="date" value="<?=$dateValueYouPassIn;?>"

As an example, this seems more manageable to me.  the EDT is for me - 
that's my timezone.  You'd need to adjust yours to start with, but 
everything else should work OK.  You're left with arrays that will get
submitted to PHP like

$sur[0600] etc.

if you did this...

while (list($k,$v) = each($num)) {
        $n = $num[$k];
        $s = $sur[$k];
        $g = $giv[$k];
        $a = $apt[$k];
        $p = $ph[$k];
        $c = $c[$k];
        $f = $fs[$k];
$sql = "insert into info (date,time,num,sur,giv,apt,ph,c,fs) values (";
$sql .= "'$date','$k','$n','$s','$g$','$a','$p','$c','$f')";
// do SQL processing here

Realize this isn't fully functioning code, but might give you a better 
idea on how to approach it.

Hope that helps...

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to