Alternative to a multidimensional array??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Hajj

    Alternative to a multidimensional array??

    I've got an app I'm working on and a benefit to my users versus the
    old application is dynamic forms. I didn't want to do it at first but
    I figured it's something I'll have to do and the added benefit is
    experience. Enough of the filler...

    I'm generating the forms with javascript, based on information I know.
    I use that information to tag the fields with that information. I
    can't go into too much detail as I don't have the code with me right
    now. Basically I'm tagging the fields like this:

    date_<full date>_entry(n)_ fieldname(n)

    it's the easiest way I can think of. On the back side I'm building a
    multi array like this(or similar):

    $dates = array();

    foreach ($_POST as $key =$value) {
    $key = strireplace("da te_", "", $key);
    $keys = explode("_", $key);

    $date = $keys[0];
    $entry = $keys[1];
    $field = $keys[2];

    if (!in_array($dat e, $dates)
    $dates [] = $date;
    }

    $date[$entry][$field] = $value;
    $keys = array();
    $date = "XX"; //clear them out...
    $entry = "XX";
    $field = "XX";

    }

    easy building? Extracting to put the information in the database, not
    so much

    foreach ($dates as $date) {
    foreach($$date as $entry ) {
    foreach($entry as $field =$value) {
    $fieldNames[] = "'preappend " . $field "'";
    $fieldValues[] = "'" . $value . "'";
    }
    $insertFields = implode(",", $fieldNames);
    $insertFields .= ",preappendDate ";
    $insertValues = implode(",", $fieldValues);
    $insertValues .= "," . $date;

    mysql_query("IN SERT INTO table $insertFileds VALUES
    ($insertValues) ", $connection) or die("ya mutha");

    $fieldNames = array(); //clean up <omitted the rest>
    }
    }
    }

    Is there a more efficient way of doing this? or did I put you asleep?
    If it helps, this is basically an agenda builder.
















  • The Hajj

    #2
    Re: Alternative to a multidimensiona l array??

    Wow, no takers?

    Comment

    Working...