Using array names in html forms

Discussion in 'Web Design' started by Glenn, May 1, 2019.

to remove all ads.
  1. Glenn

    Glenn Member

    I have tried everything I can think of to use to get array names in a form name. Either I am using the php code wrong to execute them or how I'm putting them in just isn't right. I'll give an example.

    I pick out the songs each week at church for service. I keep all of the songs we sing in a database and I change the date we sing them. If I pick out 6 songs and change the date, I have to do it one at a time with over 100 forms and submit buttons. I'd like each song to have its own if where I have something like $date[1], $date[2] etc. Then when I submit it, it will change all with one submit.

    I have a different page that has many more pieces of data that I have set to 100 per page. Therefore, each will have a different id attached to it so I use a counter $x. When I try to set this up as name = "$name[$x]" it doesn't work. I am using the escape with the "". I have changed it around so much that I'm probably repeating myself now.

    How do I set this up?
  2. Glenn

    Glenn Member

    What I currently have looks something like this.

    echo "Title<input type=\"text\" name=\"shortDesc[$x]\" size=\"40\">\n";
    I've tried several ways to get the submitted data. Here's one of many.

    $shortDesc = $_POST['shortDesc']['36'];
    echo $shortDesc

Share This Page