John Stoffel - 2003-02-05

Hi all,

I've discovered phplib and oohforms and I really like what I see, it's really helped me speed up development of a web site DB project I'm working on.

Unfortunately, I'm kinda stuck with how to get the input data *out* of the various form elements I've created.  The docs and examples on the sanisoft web site leave alot to be desired and I haven't managed to figure this out.

Basically, I've got a form with a couple of fixed elements, and then a couple more where I can have one or more elements.  In this case, I use something like this to create them:

# References setup, 1 to start
for ($x = 0; $x < $refscnt; $x++) {
$f->add_element(array("type" => "text",
                        "name" => "ref$x",
                        "value" => "",
                        "size" => 60,
                        )
                );
}

$f->add_element(array("type" => "submit",
        "value" => "More",
        "name" => "addref",
        )
        );

$f->add_element(array("type" => "hidden",
        "value" => 1,
        "name" => "refscnt",
        )
  );

This is kinda hacky, but works.  When the user clicks on the submit button, I can create an extra Ref input form element.

But for the life of me, I can't figure out how to get the damm data out.  Why doesn't this work as given below?

    for ($x = 0; $x < $refscnt; $x++) {
      $tmp = "ref$x";
      $val = $$tmp;
      echo "[$val]<br>\n";
      #echo "INSERT into REF (REFID,name,HDID)<br>\n";
      #echo "VALUES ('', ','$HDID')<br>\n";
    }

Basically, I think I need to somehow eval or conver the name "ref$x" into $ref0, $ref1, $refN and then pull the the values inside that element.

If anyone has any suggestions on how I could get this going, I'd really appreciate it.  And if people want, I'll post my full source code as well.

Thanks,
John