web form data to arrays?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have a script which retrieves rows from DB and prints them to a user 
editable form to a web page. I don't know how to print the form objects so 
that all editable fields are put to arrays for updating them to DB. I have 
tried to create arrays sarjanID[] etc. but havent got it to work...

Pls. see code below.

Thanks
-Will

$sql = "SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 
'sorter' ASC";
$row = mysql_fetch_row($result);
$result = mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
while ($num >= $cur) {
   $row = mysql_fetch_array($result);
   $id = $row["id"];
   $nimi = $row["nimi"];
   $kilpailutyyppi = $row["kilpailutyyppi"];
   $sarjataulukko = $row["sarjataulukko"];
   $joukkueitakpl = $row["joukkueitakpl"];
   $sorter = $row["sorter"];
   $kilpailut[] = array("$id", "$nimi", "$kilpailutyyppi", "$sarjataulukko", 
"$joukkueitakpl", "$sorter");  //create arrays here
   $cur++;
}

......

foreach ($kilpailut as $value) { //print arrays to a web form
   if ($value[3] == 1) {
  $staulu = "Kyllä";
 } elseif ($value[3] == 0) {
  $staulu = "Ei";
 }

 print "<input type=\"hidden\" name=\"sarjanID[ID]\" value 
=\"$value[0]\">\n";
 print "<input type=\"text\" name=\"sarjanID[nimi]\" size=\"20\" 
maxlength=\"20\" value =\"$value[1]\">\n";
 print "<select name=\"sarjanID[tyyppi]\">\n";
 print "<option selected>$value[2]</option>\n";
 print "<option>Sarja</option>\n";
 print "<option>Cup</option>\n";
 print "</select>\n";
 print "<select name=\"sarjanID[sarjataulukko]\">\n";
 print "<option selected>$staulu</option>\n";
 print "<option>Kylla;</option>\n";
 print "<option>Ei</option>\n";
 print "</select>\n";
 print "<select name=\"sarjanID[joukkueitayht]\">\n";
 print "<option selected>$value[4]</option>\n";
     for ($i=3; $i<=20; $i++ ) {
    print "<option>$i</option>\n";
    }
 print "</select>\n";
 print "<input type=\"text\" name=\"sarjanID[sortteri]\" value 
=\"$value[5]\">\n";
 print "<input type=\"checkbox\" name=\"poista\">Poista kilpailu<br><br>\n";
} 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux